Column to display number of pages in PDF

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
dogeatdog
Posts: 42
Joined: 29 Sep 2019 04:04

Column to display number of pages in PDF

Post by dogeatdog »

I saw an old post about this but couldn't see an answer exactly. I have been bumping around trying things for a while now.

I would be so grateful if I could get it to work. I tried the inbuilt pages property but it only seems to work on DOCX not PDF.

I checked Windows file explorer and it doesn't display the page count either. I am using Adobe and ideally don't want to change, is there a script I can put into the column property? I would like to do this at work and I cant modify anything outside XY.

Thanks in advance.

highend
Posts: 13339
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Column to display number of pages in PDF

Post by highend »

Scripted custom column...

Code: Select all

    $result = runret(lax("D:\Tools\@Command Line Tools\poppler_x64\pdfinfo.exe" "<cc_item>"), , 65001);
    $pages  = regexmatches($result, "^Pages:.+?$");
    return regexmatches($pages, "\d+$");
pdfinfo: https://github.com/oschwartz10612/poppl ... s/releases
One of my scripts helped you out? Please donate via Paypal

Horst
Posts: 1093
Joined: 24 Jan 2021 12:27
Location: Germany

Re: Column to display number of pages in PDF

Post by Horst »

Using one of the x-PDF tools, you can get the number of pages with the -meta switch.
Create a script which extracts the Pages: line and make a custom column with it.

Code: Select all

Usage: pdfinfo [options] <PDF-file>
  -f <int>          : first page to convert
  -l <int>          : last page to convert
  -box              : print the page bounding boxes
  -meta             : print the document metadata (XML)
  -rawdates         : print the undecoded date strings directly from the PDF file
  -enc <string>     : output text encoding name
  -opw <string>     : owner password (for encrypted files)
  -upw <string>     : user password (for encrypted files)
  -cfg <string>     : configuration file to use in place of .xpdfrc
  -v                : print copyright and version info
  -h                : print usage information
  -help             : print usage information
  --help            : print usage information
  -?                : print usage information
Example output:

Code: Select all

C:\Temp\PDF>C:\Tools\xpdf-tools\pdfinfo.exe -meta "Marschner Küchenrollladen.pdf"
Keywords:       CreatedByIRIS_Readiris_14.1
Author:         xxxx@xxx.com
Creator:        Readiris Build 7941
Producer:       Readiris Build 7941
CreationDate:   Tue Aug 25 21:05:10 2020
Tagged:         yes
Form:           none
Pages:          1
Encrypted:      no
Page size:      595 x 841 pts (rotated 0 degrees)
File size:      202713 bytes
Optimized:      no
PDF version:    1.5
Highend was faster :)
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
Portable XYplorer (actual version, including betas)
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.73

dogeatdog
Posts: 42
Joined: 29 Sep 2019 04:04

Re: Column to display number of pages in PDF

Post by dogeatdog »

Guys, I am beyond happy i got this working in 5 minutes thanks to you both.

I love this community, this is a huge quality of life thing for me at work. :biggrin: :appl:

Post Reply