empira / PDFsharp

PDFsharp and MigraDoc Foundation for .NET 6 and .NET Framework
https://docs.pdfsharp.net/
Other
530 stars 132 forks source link

Wrong page number when reading a simple pdf #129

Open ffbboy30 opened 4 months ago

ffbboy30 commented 4 months ago

Hello, PDFsharp-gdi.zip

The problem is simple the nNbpages is 1 instead of 14

Here is my code from the issue template The code is quite simple var pdfDocument = PdfReader.Open("CE EMR 8029635 - TCE-121190056.pdf"); int NbPages = pdfDocument.Pages.Count; Console.WriteLine(NbPages.ToString());

I put the pdf file in the debug directory

Thanks for your help

ThomasHoevel commented 4 months ago

It would have been much easier if you would have used the template as intended. You sent a ZIP file without code and without .SLN file.

PDFsharp only find 1 page. Further investigation pending.

ffbboy30 commented 4 months ago

Sorry here is the full template Full template.zip

Use the PDFsharp-gdi solution Thanks

ThomasHoevel commented 4 months ago

Please note that this is not a "simple PDF".

When opened with Google Chrome, there is only a single page. That's the only regular page in the PDF and that's the page that PDFsharp also finds. When opened with Adobe Reader, there are 14 pages. When opened with Firefox, there are 24 pages. Opera and SumatraPDF only find one page.

ffbboy30 commented 4 months ago

Thanks to take time to answer. So, Is there a solution to get the good number of page 14 with pdfsharp because my application use the pdfsharp api.

Thanks

ThomasHoevel commented 4 months ago

AIUI Adobe Reader creates the 14 pages "on the fly" from meta data included in the PDF and Firefox creates 24 pages from the same meta data.

PDFsharp does not have the capabilities to render those pages "on the fly". I did not check if you can easily access the meta data using PDFsharp.

ffbboy30 commented 4 months ago

Yesterday , I've tested with the adobe API and it found only 1 page too. Is it possible to read this metadata directly and bypass pdfsharp only for the number of pages ?