These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Using Javascript to retreive PDF (document) version

CL_User
Registered: Dec 20 2007
Posts: 3

Hi,
Can I use javascript to get a PDF version ? since the web application must use certain Acrobat version, so I need to do some checking of the PDF document version.

Thx

lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
Lori Defurio has a tip on how to do this at:
http://partners.adobe.com/public/developer/en/tips/lc_viewer_version.pdf

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

CL_User
Registered: Dec 20 2007
Posts: 3
Hi Ikassuba, that's not what I mean. Actually what I need is like this:
I have a web application that involves sending documents in form of PDF to some company server that only accept PDF version 1.3 (I know it's quite old version they used). So before uploading the files, I need to make sure that the PDF files that is going to be uploaded is in the correct version, so is it possible to check the pdf version using javascript (without openning the PDF files itself in Adobe Acrobat) ? Or do you have any other suggestion in this matter ?

Thx
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Since the version number has a lot to do with the features of the Acrobat display capabilities and what JavaScript properties and methods are available, I would create the PDF compatible to version 1.3 (PDF 4.X) and write all JavaScript to version 4.

Although one can use the optimzer or reduce file size to generate a PDF to the correct version for compatiblity neither will correct or verify the JavaScript will work with any specific version.

George Kaiser

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I agree with George. Use the optimizer to convert your PDFs to ver 1.3 before submitting them. With the provission that you might lose some functionality.

If you really want to get the version number, there is an undocumented function that could help, but it only works on Acrobat Pro and Standard. It will not work in Reader.

The PDF version number is in the first few bytes of the PDF file. So all you have to do is grap these bytes and you can get the info you want.

Run this code from the Console Window.

var stmDoc = Collab.documentToStream(this)
var strDoc = util.stringFromStream(stmDoc);
var strVer = strDoc.substr(5,3)
console.println("The PDF version is: " + strVer);

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script