PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Jan 27, 2021 12:06 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 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: 610
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: 7
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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group