Hi , I need to write a text in top right corner of a PDF, but the PDF is non editable.
any solution to it, please suggest.
I need to write a Doc reference number and Date in the PDF.
Hi , I need to write a text in top right corner of a PDF, but the PDF is non editable.
any solution to it, please suggest.
I need to write a Doc reference number and Date in the PDF.
You could use the PDFsharp-GDI library (I recently used version 6.1.1 and it worked well).
Then in an Invoke Code you’d do something like this…
Dim PDFDocument As New PdfSharp.Pdf.IO.PdfReader.Open("C:\test\test.pdf", PdfSharp.Pdf.IO.PdfDocumentOpenMode.Import)
Dim page = PDFDocument.Pages(0)
Dim gfx = PDFSharp.Drawing.XGraphics.FromPdfPage(page)
Dim font = New PdfSharp.Drawing.XFont("Helvetica",30)
gfx.DrawString("Your text", font, PdfSharp.Drawing.XBrushes.Black,New PdfSharp.Drawing.XRect(0,1,2,3), PdfSharp.Drawing.XStringFormats.TopLeft
PDFDoc.Save("C:\test\new.pdf")
PDFDoc.Close
I haven’t tested it, but that should be pretty close. The (0, 1, 2, 3) which is a rectangle’s top left x, top left y, width, and height…is where you tell it where to put the text. You can use page.width, page.height etc to calculate appropriate values for your needs.
try below thread
follow the URL, might be it’ll helpful
thank you for the response,
Does this code works on the PDF which is Non editable ?
It should, because what it’s doing is reading in the existing PDF, writing text over top of it, then writing it out to a new PDF.