Page Number of a PDF document

i am trying to use
{ sr = new streamreader([path of a pdf]) and matches = regex.Matches(sr.ReadToEnd(),“/Type\s*/Page[^s]”) } with { pages = matches.Count.ToString } to find out the total no. of pages of a pdf document.

However, this method may count more pages (e.g. 167 pages but the actual no. is 162 only). Is there any easy way to find the no. of pages of a pdf document??

Thanks a lot !!

Above is the link to download the sample pdf. Thanks.

Hello @ivan123, I have added GetPageCount activity to PdfSharp.Activities package so you can easily get the number of pages of PDF.

5 Likes

@Timber Thanksss ! It really helps!

1 Like

Hello Timber

I installed the PdfSharp Activity. But the activity GetPageCount is not in the package.

second:
i ust the extract PDF Pages Activity but i don 't now what to write into the range part of the Activity. I now “1,2,3,4” but with 50 pages i like to use “All” but that won 't work.
See also my other topic

[quote=“Timber, post:3, topic:54713, full:true”]
Hello @ivan123, I have added GetPageCount activity to PdfSharp.Activities package so you can easily get the number of pages of PDF.

What needs to be the input in Range with the Extract pdf Pages Activity?

Greetings

Hey @nicostegeman, maybe you didn’t installed the latest version? 1.0.0.13 is the one with GetPageCount.

If you have 50 page PDF and want to get 50 PDFs of 1 page each, then use SplitPDF activity and set GroupOf property to 1.

Hi Timber,

Thanks for sharing your work!

I’m using the Studio CE, and installed the latest version of PdfSharp.
However, I can’t find any activities on the “activities list”.

Can’t uninstall and reinstall the package.

Could lend a hand on to me?

Check the following screenshots:

BR
Helliton

@Timber
Thank you for your work in the PDF extensions activities! However ,
i too , am not seeing the get page count activity in 2018.2.3

after uninstalling (removing from activities feed and in %localappdata%\uipath\activties)
and reinstalling …
(adding the v1.0.0.13 vaidotas activity and pdfsharp.1.50.4845-rc2a.nupkg to the same activities locations)
… it is now working, thank you!