Solved

How to retrieve the properties of a PDF file

Posted on 2007-04-06
3
661 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now