Hi.
I need some help.
I was searching for how to write on an existing PDF file.
I have this code here:
Code:
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
PdfDocument PDFDoc = PdfReader.Open(@"C:\Users\Userofthispc\Documents\Test.pdf", PdfDocumentOpenMode.Import);
PdfDocument PDFNewDoc = new PdfDocument();
for (int Pg = 0; Pg < PDFDoc.Pages.Count; Pg++)
{
PdfPage pp = PDFNewDoc.AddPage(PDFDoc.Pages[Pg]);
XGraphics gfx = XGraphics.FromPdfPage(pp);
XFont font = new XFont("Arial", 30, XFontStyle.Italic);
gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(pp.Width / 2, pp.Height / 2 + 85, pp.Width, pp.Height), XStringFormats.Center);
}
PDFNewDoc.Save(@"C:\Users\Userofthispc\Documents\Testv2.pdf");
The code should work (I think), but when I run it, it doesn't write anything.
Can you help me?