Solved

How to retrieve the properties of a PDF file

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 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