Sign in to follow this  
Followers 0
tauruzian

Get PDF page size

4 posts in this topic

Hi Gurus,

I'm a newbie in AutoIT. Is there any where I can get PDF properties values. I need to take PDF page size in properties. Please advice.

Thanks 

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

@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.
 

Share this post


Link to post
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
Sign in to follow this  
Followers 0