As we all know, PDF is a file format created by Adobe®, it lets you can view and print a file exactly as the author designed it, without needing to have the same application or fonts used to create the file.

PDF has become an Internet standard for electronic distribution because the look and feel of the original document complete with fonts, colors, images, and layout. PDF is so userful, can we render PDF contents in Adobe AIR applications? If can, how to do it?

PDF-maker-256x256

We can load the PDF content using a data attribute in the object tag, versions 8.2.3 and 9.0 of Adobe Reader and Acrobat do not allow cross-scripting PDF content in the AIR application sandbox(Here is details).

So, We can use HTMLLoader to load the PDF and add the HTMLLoader to the window of AIR applications.

Following is the source code for redering content in AIR applications.

  1. if(HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK)
  2.  
  3. {
  4.  
  5. var htmlLoader:HTMLLoader = new HTMLLoader();
  6.  
  7. var url:URLRequest = new URLRequest(pathUrl); //URL to the file
  8.  
  9. htmlLoader.width = windowWidth; //width of the content area
  10.  
  11. htmlLoader.height = windowHeight; //height of the content area
  12.  
  13. htmlLoader.load(url);
  14.  
  15. //wrapping into UIComponent
  16.  
  17. var holder:UIComponent = new UIComponent();
  18.  
  19. holder.addChild(htmlLoader);
  20.  
  21. addChild(holder); //add it to any container
  22.  
  23. }

Jeff Swartz worte an article describes how to communicate from JavaScript in the HTML page with JavaScript in a PDF page. if interesting, enjoy pls!

http://www.adobe.com/devnet/air/ajax/quickstart/scripting_pdf.html

For help, advice, tips and tricks, challenges, feel free to visit ourDoNotYet forum or Submit your good resource to share.

Reminder: Unless stated otherwise, all resources published on this site are NOT for commercial use. To use any resource from this site for commercial purposes, please contact the author.

Related Posts