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:
- Add headers/footers to existing PDFs
- Create PDF packages
- Selectively optimize PDF size
- Extract text from PDFs
- Extract images from PDFs
- Create high quality thumbnails
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:
- noattachments
- nobookmarks
- nocomments
- nofonts
- nojavascript
- nolinks
- nometadata
- nothumbnails
Code looks like this:
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:
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:
You have options to prefix the images, and pick image formats
As you can see, the engineers added some cool functionality here.
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.
LikeLike
Excellent. Creating a thumbnail of a PDF would be VERY useful for my content management app.
LikeLike
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
LikeLike
Thanks for the tip. It helped me solve a problem .
P.S. The best
torrents search engine.
LikeLike
Is there a way to lock down a PDF in CF9 so that viewers can not do a save or save as?
LikeLike
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
LikeLike