PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Replace few words in PDF
http://forum.pdfsharp.de/viewtopic.php?f=2&t=4213
Page 1 of 1

Author:  vijendravijendra [ Mon Dec 28, 2020 4:16 pm ]
Post subject:  Replace few words in PDF

Hello,
I have been provided a 12 page PDF document by our marketing team.
I have no idea how this PDF was created in the first place but I was clearly told that I wont be provided with the source of the PDF document.

Now, I have to read this PDF and replace values like customer name, address etc and generate a new PDF document for each customer.
Can I achieve this using PDFSharp? If so, can anyone help me with the details of the source code. Thank you!

Regards.

Author:  TH-Soft [ Mon Jan 04, 2021 9:50 am ]
Post subject:  Re: Replace few words in PDF

vijendravijendra wrote:
Can I achieve this using PDFSharp?
That depends on your skills. It won't be easy.

vijendravijendra wrote:
If so, can anyone help me with the details of the source code.
Maybe you underestimate the necessary effort.

Author:  pdfuser1 [ Sat Jan 23, 2021 3:09 am ]
Post subject:  Re: Replace few words in PDF

vijendravijendra wrote:
I have been provided a 12 page PDF document by our marketing team.

Now, I have to read this PDF and replace values like customer name, address etc and generate a new PDF document for each customer.
Can I achieve this using PDFSharp?

I did something similar a while back. Mine was a one-page PDF which needed to be customized for each customer. The approach I used was:

  • Step 0 (outside of your code, manually by hand): Create a template PDF file from the original document by deleting all cusomized/variable information (name, address etc.) and leaving just blank space there
    • You may need 12 template files for each page in your PDF

Then your code will do the following:

  1. Open the template PDF file(s) into a PDfPage object(s)
  2. Loop through your customer records and:
    • Create a new PdfDocument
    • Create a PdfPage using your template (you may need to loop through your individual 12 templates here)
    • Draw the customer info (name, address etc.) on the page (use XGraphics, XFont and XTextFormatter objects and DrawRectangle and DrawString methods)
    • Save each PDF document

It may be tedious (especially if there is a lot of data pieces to insert, but it's doable).

Author:  kensands [ Wed Jan 27, 2021 9:29 am ]
Post subject:  Re: Replace few words in PDF

If the original pdf does not have personal data ie if the current address is something like
ADDRESS1
ADDRESS2
ADDRESS3
POSTCODE

Then it's actually pretty easy, add a white rectangle over the current address then add your new details on top of that.

Do NOT do this if the original has personal data as it'll still be there and could be extracted easily.

Author:  rsoeung [ Mon Feb 01, 2021 10:33 pm ]
Post subject:  Re: Replace few words in PDF

I don't know anything about your C# programming skills. Perhaps a better path to take is to purchase a pdf editing tool. https://acrobat.adobe.com/us/en/acrobat.html or https://www.foxitsoftware.com/pdf-editor and many others.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/