Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 652341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:15:43+00:00 2026-05-13T22:15:43+00:00

I’m using AlivePDF to create a PDF file, then save it to the desktop.

  • 0

I’m using AlivePDF to create a PDF file, then save it to the desktop. I can then use an HTMLLoader to display my lovely PDF file.

Now, the print button in Adobe Reader works fine. However, there will be young children using the app, so I’d like to have a big “Print” button right above it.

I figured I could just start up a print job and feed it my HTMLLoader. This won’t work because the HTML loader rasterizes the content.

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:15:43+00:00Added an answer on May 13, 2026 at 10:15 pm

    One answer I have found in order to solve this problem is called Cross-scripting PDF content. The idea is that a PDF can have embedded JavaScript, which can be called from the JavaScript within the HTML page “housing” said PDF (object tag only, no embed).

    This site was of particular help. I had to simplify the JavaScript from that page down quite a bit. I kept getting syntax errors.

    I also need my program to generate the PDF and the HTML content. I cannot ship a single PDF with embedded JS and an HTML file pointing to it. They need to be dynamically generated by the user. Here is a basic rundown:

    private function printText(text:String):void
    {
     var p:PDF=new PDF(Orientation.PORTRAIT, Unit.MM, Size.LETTER);
     p.addPage();
     p.addText(text, 100, 100);
     p.addJavaScript(this.getJavascript());
     var f:FileStream=new FileStream();
    
     var html:File=File.desktopDirectory.resolvePath("exported.html");
     f.open(html, FileMode.WRITE);
     f.writeUTF(this.getHtml());
     f.close();
    
     var file:File=File.desktopDirectory.resolvePath("exported.pdf");
     f.open(file, FileMode.WRITE);
     var bytes:ByteArray=p.save(Method.LOCAL);
     f.writeBytes(bytes);
     f.close();
    

    Now that we have our two files, HTML and PDF, we can view the PDF, and create a giant purple print button for our younger / sight-impared users.

     if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK)
     {
      var win:PrintTitleWindow;  //the window w/giant button
      var htmlLoader:HTMLLoader=new HTMLLoader();
      var url:URLRequest=new URLRequest(html.url);
      htmlLoader.width=880;
      htmlLoader.height=(appHeight - 150);  //i figure out the height elsewhere
      htmlLoader.load(url);
      var holder:UIComponent=new UIComponent();
      holder.addChild(htmlLoader);
      win=PrintTitleWindow(PopUpManager.createPopUp(mainWindow, PrintTitleWindow, true));
      win.width=900;
      win.height=(appHeight - 50);
      win.addChild(holder);
      win.addContent(htmlLoader);
      PopUpManager.centerPopUp(win);
     }
    }
    

    Here is the JS and HTML I used. I’m adding these in here for laughs. I’m sure there is a better way to do this, but I’m tired and it is late.

    private function getJavascript():String
    {
     return 'function myOnMessage(aMessage) { print({ bUI: true, bSilent: false, bShrinkToFit: true }); } function myOnDisclose(cURL,cDocumentURL) { return true; } function myOnError(error, aMessage) { app.alert(error); } var msgHandlerObject = new Object(); msgHandlerObject.onMessage = myOnMessage; msgHandlerObject.onError = myOnError; msgHandlerObject.onDisclose = myOnDisclose; this.hostContainer.messageHandler = msgHandlerObject;';
    }
    
    private function getHtml():String
    {
    return '<html><head><script>function callPdfFunctionFromJavascript(arg) { pdfObject = document.getElementById("PDFObj");pdfObject.postMessage([arg]);}</script></head><body><object id="PDFObj" data="exported.pdf" type="application/pdf" width="100%" height="100%"></object></body></html>';
    }
    

    The PrintTitleWindow is a simple title window with the print button on it. The code to print is simple.

    myHtmlLoader.window.callPdfFunctionFromJavascript('Print');
    

    Eh Voila! I have a gigantor-print-button like so:

    alt text
    (source: cetola.net)

    Hitting that big purple print button is the same as hitting the print icon in the PDF toolbar. The difference for me is that my users, who could be elementary or middle-school kids, won’t have to look around for the stupid button.

    So, it’s a long way around the block. Still, if you need to print and can’t rely on that adobe toolbar button, here’s your answer 🙂 .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.