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

Add Page Number & Sort pages in pdf using Migradoc/Pdfsharp
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4414
Page 1 of 1

Author:  Ash [ Tue Jan 31, 2023 6:48 pm ]
Post subject:  Add Page Number & Sort pages in pdf using Migradoc/Pdfsharp

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.

Author:  () => true [ Wed Feb 01, 2023 8:29 am ]
Post subject:  Re: Add Page Number & Sort pages in pdf using Migradoc/Pdfsh

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.

Author:  Ash [ Wed Feb 01, 2023 4:46 pm ]
Post subject:  Re: Add Page Number & Sort pages in pdf using Migradoc/Pdfsh

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 ?

Author:  TH-Soft [ Wed Feb 01, 2023 5:04 pm ]
Post subject:  Re: Add Page Number & Sort pages in pdf using Migradoc/Pdfsh

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

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