TerrenceRyan.com

I'm a 35 year old redhead geek from Philly.
I'm currently a Developer Evangelist for Adobe.
Also the author of Driving Technical Change

ColdFusion 9 PDF Enhancements

6 Comments

Another of the less visible, but still cool features in ColdFusion 9 are the enhancements we've made to <cfpdf>. We've added the ability to:

Of these features, my personal favorites are optimization and extraction.

Optimization

PDFs can do a lot. Consequently, PDFs size can swell due to the presence of extra information, metadata, and embedded files. The optimize feature allows you to remove specific types of extras in order to selectively reduce the size of your PDF. But you can retain features that you need. When you take action="optimize" the following options are open to you:

Code looks like this:

<cfpdf    action="optimize"
      source="#ExpandPath('./UserGroupTour2009.pdf')#"
      destination="#ExpandPath('./UserGroupTour2009Opt.pdf')#"
      noattachments = true
      nobookmarks = true
      nocomments = true
      nofonts = true
      nojavascripts = true
      nolinks = true
      nometadata = true
      />

As you can see, the code is pretty straightforward. I've seen reductions of 65-75% on PDF size when using all options.

Extraction

Yes, you can get at the text or embedded images of a PDF with ColdFusion 9.

Here's the code to get at the text of a PDF:

<cfpdf action="extracttext"
      source="#ExpandPath('./UserGroupTour2009Opt.pdf')#"
      name="cfref"
       />


<cfdump var="#XMLparse(cfref)#" >

That code will extract the text of a PDF to XML. The structure divides the content into pages, so you can quickly get at content on particular pages, etc.

You have a few options that I'm not showing though. You can get the content as just a string. You can selectively get page numbers. You can even get XY coordinates for all of the words in the document.

Getting images is similar; you plug in a PDF, and send the images to a directory:

<cfpdf action = "extractimage"
   source = "#ExpandPath('./UserGroupTour2009Opt.pdf')#"
   destination = "ExpandPath('./images')" />

You have options to prefix the images, and pick image formats

As you can see, the engineers added some cool functionality here.

6 responses so far ↓

  • 1 dev

    Why don't enhance the cfdocument to print web to PDF ? I think it is better to embed WebKit rendering engine in CF for generating web thumbnails on the fly.
  • 2 Calvin

    Excellent. Creating a thumbnail of a PDF would be VERY useful for my content management app.
  • 3 Aaron Neff

    Regarding WebKit.. yes, it looks like the upcoming JWebPane (based on WebKit) may be the logical replacement for the end-of-life ICEbrowser SDK.

    -Aaron Neff
  • 4 Anna LKee

    Thanks for the tip. It helped me solve a problem .

    P.S. The best
    <a href="http://www.queentorrent.com">torrents search</a> engine.
  • 5 Christine D

    Is there a way to lock down a PDF in CF9 so that viewers can not do a save or save as?
  • 6 DypeNeabe

    http://nails-art-design-1.blogspot.com/2011/03/candle-nail-art-design.html - nail art stiletto nail french grey
    http://beautiful-nail.blogspot.com/2011/04/beautiful-long-gel-nails.html - nail art design french fries
    http://beautiful-nail.blogspot.com/2011/04/flower-beautiful-nails_01.html - flower nail art disign
    http://beautiful-nail.blogspot.com/2011/04/flower-beautiful-nails.html - nail art swimsuit for spring break
    http://nails-art-gallery.blogspot.com/2011/03/nail-art-fine-liner-gallery.html - french red rhinestone trims
    http://3d-nail-art.blogspot.com/2011/03/3d-nail-art-decals.html - nail art disign corset

Leave a Comment









Categories

Monthly Archives

Tag Cloud

coldfusion web development flex coldfusion builder appearances squidhead coldfusion builder extensions higher ed html5 flash builder air mobile android driving technical change adobe apptacular running a coldfusion shop adobemax06 movable type flash catalyst flash css blackberry adobemax07 adobemax08 hero finicky adobemax09 holy crap i’m a mobile developer centaur phonegap basecamp cfc whichelement unfuddle motorola metablog irrational characters ios git evangelism edge devices code reviews ant wharton subversion security rhino philly philadelphia multidevice knowledge@wharton jobs javascript java browserlab adobemax10 adobe tv unfuddlecfc svnauth.cfc semantic html semantic html responsive web design qnx nlb linux jquery mobile it github flexorg fireworks eclipse dreamweaver apps apple adobemax11