Solved

How to retrieve the properties of a PDF file

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

Save on storage to protect fatherhood memories

You're the dad who has everything. This Father's Day, make sure your family memories are protected. My Passport Ultra has automatic backup and password protection to keep your cherished photos and videos safe. With up to 3TB, you have plenty of room to hold the adventures ahead.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Remove Index.php in Codeigniter 12 56
Grub Broken on Ubuntu 16.04 LTS, Mate 1.14 GUI 5 204
Script 12 133
Help with a redirect in web.config file 8 26
In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

23 Experts available now in Live!

Get 1:1 Help Now