Source language: Translate to:

Help for VBScript and retrieve number of page in PDF file

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Help for VBScript and retrieve number of page in PDF file

Postby Geo » Sat Dec 05, 2015 1:56 pm

Hello everyone,
I've never used the VBScript function NeoBook.
I try to use the following code, but does not.
By plainement against it functions in Excel.
The goal is to count the number of pages in PDF files in a folder.
Can you help me.
Thank you.
Code: Select all
'Function GetPageNum(PDF_File As String)
Dim PDF_File 'as string
Dim FileNum 'As Long
Dim strRetVal 'As String
Dim RegExp
Set RegExp = CreateObject("VBscript.RegExp")
RegExp.Global = True
RegExp.Pattern = "/Type\s*/Pages"
FileNum = FreeFile
Open PDF_File For Binary As #FileNum
strRetVal = Space(LOF(FileNum))
Get #FileNum, , strRetVal
Close #FileNum
GetPageNum = RegExp.Execute(strRetVal).Count
publication.nbSetVar "[PDFNombrePages]", GetPageNum
End Function

Sorry for my english very bad.
Bonjour à tous,
Je n'ai encore jamais utilisé la fonction VBScript de Neobook.
J'essaie d'utiliser le code suivant, mais ne fonctionne pas.
Par contre il fonctionne plainement dans Excel.
Le but est de compter le nombre de pages contenues dans les fichiers PDF d'un dossier.
Sauriez-vous m'aider.
Merci.
User avatar
Geo
 
Posts: 6
Joined: Tue Feb 28, 2006 4:10 pm
Location: Belgium, somewhere in Europe


Re: Help for VBScript and retrieve number of page in PDF fil

Postby Geo » Sun Dec 06, 2015 6:23 am

Hello forum

Hi Tony,
Lots of interesting things on your link.

I try to use the pdfinfo.exe utility.
On the command line, no problems
Code: Select all
pdfinfo.exe test1.pdf > txxt.txt

The txt file is created with the information.
In NeoBook, I use the command
Code: Select all
Run "[pubdir] pdfinfo.exe" "test1.pdf> txxt.txt" "RunOnce + Wait" "" ""

The TXT file not created (and I see briefly display the result in a command window)
An idea ?
Tanks
User avatar
Geo
 
Posts: 6
Joined: Tue Feb 28, 2006 4:10 pm
Location: Belgium, somewhere in Europe

Re: Help for VBScript and retrieve number of page in PDF fil

Postby Tony Kroos » Sun Dec 06, 2015 8:13 am

run it using console:
Run "cmd.exe /C [#34][pubdir]pdfinfo.exe[#34]" "test1.pdf> txxt.txt" "RunOnce + Wait" "" ""
dont forget to use quotes #34 if filepath has empty space(s)
maybe you should use "/C [#34][pubdir]pdfinfo.exe[#34] test1.pdf> txxt.txt" as run parameters (cant remember how run it properly, dont have nb installed to check it out)

you may run cmd.exe manually and test your run string until it works
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests