#1 2020-03-12 10:47

Lucien
Member
Registered: 2020-03-12
Posts: 1

Nombre de pages (pages number)

Bonjour,

Je cherche à insérer le nombre de pages des fichier PDF

Est-ce possible?

Merci

I want to insert the number of pages of PDF files
Is it possible?
Thank you

Offline

#2 2020-03-12 17:11

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,440

Re: Nombre de pages (pages number)

Yes, it is possible with the use of Pascal Script rule in combination with Xpdf command line tools.

Download Xpdf command line tools and extract "pdfinfo.exe" into ReNamer's folder.

Then, add the following Pascal Script rule:

{ Extract PDF page count using Xpdf }

const
  EXE = 'pdfinfo.exe -enc UTF-8';
  TAG = '[\r\n]Pages\s*\:\s*(.*?)[\r\n]';

var
  Command, Output: String;
  Matches: TWideStringArray;

begin
  Command := EXE+' "'+FilePath+'"';
  if ExecConsoleApp(Command, Output) = 0 then
  begin
    Matches := SubMatchesRegEx(Output, TAG, False);
    if Length(Matches) > 0 then
      FileName := WideExtractBaseName(FileName) +
        ' [' + Matches[0] + ']' +
        WideExtractFileExt(FileName);
  end;
end.

This script appends the page count to the end of the filename.

The script is based on this:
https://www.den4b.com/wiki/ReNamer:Scripts:Xpdf

Offline

Board footer

Powered by FluxBB