PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 11:10 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Jan 31, 2023 6:48 pm 
Offline

Joined: Tue Jan 31, 2023 6:01 pm
Posts: 2
Hi,

I am currently using PdfSharp and MigraDoc to Merge Pdfs and from a input and create a New pdfDocument which consist of all merged pdf pages.
I have imported PDFsharp-MigraDoc package using Nuget package Manager in VisualStudio.

Requirement:

There are hundreds of pdf document to merge , so this action is done in parallel and final merged pdf document doesn't have the pages in order.

Using, MigraDoc.DocumentOjectModel I am using Sections and creating Page Header and Footer to the sections. Using paragraph I am creating pagefield
Used the 'DefineContentSection 'method of Migradoc to add the pageNumbers.

Questions:
1. I was NOT able to find a way to "Sort the Pdf pages" based on a filed (example: page number / text field) using Migradoc. There are method to add Page Number using AddPageField() and section.PageSetup.StartingNumber = 1. My requirement is to search for the pages using Page numbers in Merged Pdf document and sort them based on page numbers.
Is there a method in Migradoc/PdfSharp which can be used to achieve sorting of pdf pages?

2. Also, Is there a method to retrieve/Read Page numbers in the Pdf document. There are no direct API methods I could find like GetPageField /GetPageNumbers in Migradoc or PdfSharp dll to read pageNumber or Retrieve a field in Pdf page.

Any help to above 2 questions is appreciated.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 01, 2023 8:29 am 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
Hi!
Ash wrote:
There are hundreds of pdf document to merge , so this action is done in parallel and final merged pdf document doesn't have the pages in order.
It is up to you to keep track of the files. The final file will have the pages in the order in which they are added.

Otherwise to me it is rather unclear what you are asking.

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 01, 2023 4:46 pm 
Offline

Joined: Tue Jan 31, 2023 6:01 pm
Posts: 2
Since we are executing merge of pdf documents in thread, Merging of pages from different doc is happening in parallel and hence pages are getting merged NOT in correct in final PDF document.
Is there a method in Pdfsharp component to sort the Pdf pages in Order using Page Number or any field to reorder the pages ?


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 01, 2023 5:04 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 906
Location: CCAA
Ash wrote:
Since we are executing merge of pdf documents in thread, Merging of pages from different doc is happening in parallel and hence pages are getting merged NOT in correct in final PDF document.
Is there a method in Pdfsharp component to sort the Pdf pages in Order using Page Number or any field to reorder the pages ?
It is up to you to keep track of the files. The final file will have the pages in the order in which they are added.
PDFsharp is not thread-safe, so you must use a single thread to add pages anyway. No merging in parallel. So there is no problem to keep track of the pages and where they are coming from.

I saw your code snippet on SO and it does not help me to understand what you are asking.
https://stackoverflow.com/q/75301923/162529

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


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 49 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