Jump to content

Get PDF page size


Go to solution Solved by orbs,

Recommended Posts

with earlier versions of PDF that was indeed very easy, but with the latest versions you can't just read the file and look for the string. you will need to find a command-line tool that can query PDF and extract the details you need, then call it from AutoIt by RunWait().

there are several such tools, a quick google shows for example these: (I can't determine if they are free or limited)

http://www.pdflabs.com/tools/pdftk-server/

http://www.verypdf.com/app/advanced-pdf-tools/advanced-pdf-tools-command-line-guide.html

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Adobe Reader comes with an API. It's a bit complex for a newbie but you should find a lot of examples on the Web for Visual Basic. They can then easily be translated to Autoit.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Solution

@tauruzian, I hope you know what you're doing... because what you ask is a slippery slope when it comes to usable information. i'll explain:

here's a very simple way to do what you need (portable executable, Acrobat Reader is not needed):

1) download the xpdf package from here (GPL): http://www.foolabs.com/xpdf/download.html

2) extract it and find the file pdfinfo.exe

3) launch it with your PDF file as a parameter (you can redirect the output to a text file).

observe the output:

Producer:       Foxit Reader PDF Printer Version 6.0.1.0405
CreationDate:   10/25/13 11:20:17
ModDate:        10/25/13 11:20:17
Tagged:         no
Form:           none
Pages:          1
Encrypted:      no
Page size:      595.276 x 841.89 pts (A4)
File size:      15009 bytes
Optimized:      no
PDF version:    1.7
 
note the line in bold. simple, right?

 

wrong.

this is a simple example of a file consists of one A4 page. now observe the output of another file - that is an invoice i received by email:

Creator:        Inspire Designer 8.0.63.0
Producer:       PDF
CreationDate:   09/11/13 11:26:35
ModDate:        09/15/13 22:23:24
Tagged:         no
Form:           AcroForm
Pages:          2
Encrypted:      no
Page size:      555.591 x 864 pts
File size:      314856 bytes
Optimized:      no
PDF version:    1.4
 
now, what the heck is 555.591 x 864 pts ? 
as far as i can determine, this is a custom size, not standard. at least it prints well on A4...
I did not try, for example, A3 landscape to see what size is it...
 
you get the point? you need to foresee many sizes, and yet you may find yourself with data you won't know how to handle.
 
so it all depends on what you want to do with the data you get.
 

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...