question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting page count for pdfs

See original GitHub issue

Hi,

First of all, thanks for creating and maintaining this awesome framework!

I’m working on a project where we are using this framework to work with images and pdfs. The pdf operations in it self seems pretty easy, following your documentation:

https://github.com/dlemstra/Magick.NET/blob/master/Documentation/ConvertPDF.md

The problem or question I have to this, is that for pdfs with alot of pages in it, this operation takes forever.

So if I use the following code:

MagickReadSettings settings = new MagickReadSettings();
settings.Density = new Density(300);
using (MagickImageCollection i = new MagickImageCollection())
{
    i.Read(file, settings);
}

The read operation takes forever. 60 pages takes around 50 seconds.

What I am really interested in is actually just the page count and not so much all the extra information that I get for each page in the pdf.

If I run a similar query on the Imagemagick exe:

magick.exe indentify -verbose -ping file.pdf

then it takes only 5-6 seconds, which is a significant difference.

Is there a way or a trick with which I can speed this up?

Thanks in advance!

/Magnus

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
IanSCcommented, Aug 7, 2018

I used iTextSharp to get the number of pages.

var its = new iTextSharp.text.pdf.PdfReader( pdfFile );
var numberOfPages = its.NumberOfPages;
0reactions
dlemstracommented, Jan 18, 2021

Could you open a new issue to request support for that? And feel free to include an suggestion of how the API should look like.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to count pages in multiple PDF files?
In Adobe Acrobat Pro, go to file > create PDF > merge files into a single PDF. Then add files and select the...
Read more >
php - Get the number of pages in a PDF document
The R package pdftools and the function pdf_info() provides information on the number of pages in a pdf. library(pdftools) pdf_file <- file.path ...
Read more >
How to count pages in multiple PDF files together ...
Learn how to count pages in multiple PDF files together in Windows 11/10 using a web browser and free PDF page counter tools....
Read more >
How to count the number of pages in PDF file
How to Count the Number of Pages in PDF File · Select this folder in the left-side navigation menu. · Press the "Set...
Read more >
How can I get a total page count of a PDF before placing ...
Is there a simple way to get the count of PDFpages without going through a loop and placing the next page from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found