-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPdfEditor.cs
More file actions
27 lines (23 loc) · 793 Bytes
/
PdfEditor.cs
File metadata and controls
27 lines (23 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Drawing;
using PdfSharp.Fonts;
using PdfSharp.Snippets.Font;
using PdfSharp;
public class PdfEditor
{
static PdfEditor()
{
if (Capabilities.Build.IsCoreBuild)
GlobalFontSettings.FontResolver = new FailsafeFontResolver();
}
public void EditPdf(string filePath)
{
PdfDocument document = PdfReader.Open(filePath, PdfDocumentOpenMode.Modify);
PdfPage page = document.Pages[0];
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyleEx.Bold);
gfx.DrawString("Added this with PDFsharp", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.TopLeft);
document.Save(filePath);
}
}