Solved

How to retrieve the properties of a PDF file

Posted on 2007-04-06
3
667 Views
Last Modified: 2013-12-24
Is there a way to retrieve the properties of a PDF file in ColdFusion?  Like the Title, Author, Subject?
0
Comment
Question by:sulzener
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 18871626
One method is to use the iText library. Its built into MX 7.

<cfscript>
      filePath = "c:\myPDFFile.pdf";
      reader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(filePath);
      properties = reader.getInfo();
</cfscript>

<cfdump var="#properties#">
0
 

Author Comment

by:sulzener
ID: 18875231
aqx, Thank you.  I think you somewhat answered my question, but now I am thinking I didn't asked it throughouly enough.  When you right-click on a PDF, there is a PDF tab and a Summary tab.  Your answer provided me the data from the PDF tab, I am wondering if I can grab the info from the Summary tab?  There are some input boxes you can populate like this: Title, Subject, Author, Category, Keywords, Comments.  Any other suggestions?
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 500 total points
ID: 18878747
sluzener,

From what I understand pdf files can have different types of properties. I've used iText to retrieve the dictionary properties of a pdf file (title, subject, etc) and any metadata.

<cfscript>
      filePath = "c:\myPDFFile.pdf";
      reader = createObject("java", "com.lowagie.text.pdf.PdfReader").init(filePath);
      properties = reader.getInfo();

        metaBytes = reader.getMetaData();
        if (IsDefined("metaBytes")) {
               metaString = createObject("java", "java.lang.String").init(metaBytes);
             metaXML = XmlParse(metaString);
        }
</cfscript>

<cfdump var="#properties#">

<cfif isDefined("metaXML")>
      <cfdump var="#metaXML#">
<cfelse>
      No metadata was found
</cfif>

What you're talking about sounds like o/s file properties generated by windows. I think thats something different. You could probably retrieve that information using some sort of activeX/COM object. But unfortunately I don't know much about that.  
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question