Dear Gurus,
I'm trying to use the command I've read a few times but cannot get it to work properly. I wish to count the pages in a PDF. I have tried:
identify -format %n image.pdf
However, if it is 2 pages I get 22
If it is 6 I get 666666
If it is 55 I get 555555555555555555555555555555..........(you get the idea!)
Please can I get some help?
Thanks in advance.
PDF page count
Re: PDF page count
Thanks. I'm not the greatest coder but I put a \n, converted it to a string, searched for the first space and split the string and converted back to an integer - sure someone can do it easier but it does now work!!!
$page_count_raw=$(identify -ping -format %n\n c:\mark\temp\count\Test.pdf)
$page_count_string_all = [String]$page_count_raw
$space_index = $page_count_string_all.IndexOf(" ")
$page_count_string = $page_count_string_all.Substring(0,$space_index)
$page_count = [int]$page_count_string
$page_count_raw=$(identify -ping -format %n\n c:\mark\temp\count\Test.pdf)
$page_count_string_all = [String]$page_count_raw
$space_index = $page_count_string_all.IndexOf(" ")
$page_count_string = $page_count_string_all.Substring(0,$space_index)
$page_count = [int]$page_count_string