Solved

How to retrieve the properties of a PDF file

Posted on 2007-04-06
3
673 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

627 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