PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 3:27 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Replace few words in PDF
PostPosted: Mon Dec 28, 2020 4:16 pm 
Offline

Joined: Mon Dec 28, 2020 4:09 pm
Posts: 1
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 04, 2021 9:50 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Sat Jan 23, 2021 3:09 am 
Offline

Joined: Fri Nov 15, 2019 5:10 am
Posts: 8
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).


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 9:29 am 
Offline

Joined: Tue Jul 15, 2014 8:56 pm
Posts: 13
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 01, 2021 10:33 pm 
Offline

Joined: Sat Jan 09, 2021 7:09 am
Posts: 18
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 155 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group