Home  • Download  • Register Now!  • Benefits  • Help  • Testimonials  • Samples  • Screenshots  • Awards  • Forum  • Convert Documents Online  • Print2Flash APIs  • Print2Flash vs. FlashPaper  • Contact Us
 Help Contents

Using Print2Flash Document API for Flash documents from Web Browser and other Applications

Overview

You may access Print2Flash Document API from any application that hosts a Flash document. The specific instructions on using Print2Flash Document API depend on how the host application is implemented. The access to Print2Flash document API is implemented using External API for Flash Player. See this page at Adobe website to get information on External API and its usage: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/2/help.html?content=00001036.html  

Note: Using Print2Flash document API from other applications requires Flash Player 8 or higher.

Using Print2Flash Document API from a Web Page

First, publish a Flash document in a web page (see How to Publish a Document on the Web?).

Next, include the following code somewhere in the page header (within the HEAD tag):

<script language="JavaScript">
<!--
    function GetDoc(movieName) {
        var isIE = navigator.appName.indexOf("Microsoft") != -1;
        return (isIE) ? window[movieName] : document[movieName];
    }
// -->
</script>

Copy Code

After that you may call Print2Flash Document API functions using the following syntax:

<retvalue>=GetDoc(<movieName>).<funcname>(<parameters>)

Here <movieName> is the ID of the Flash movie embedding HTML tag (if you use HTML code generated by Save HTML command; it is equal to "Print2FlashDoc"), <funcname> and <parameters> are the function name and parameters as specified in Function Summary and <retvalue> is the variable name that receives the function return value (if any). For example, to set initial document settings after the page is loaded, e.g. to zoom document to 100 percent, go to the 5th page and activate Select Text mode for the document named Print2FlashDoc you may use the following code for the opening BODY tag:

<script language="JavaScript">
<!--
function Init() {
    GetDoc("Print2FlashDoc").setCurrentZoom(100);
    GetDoc("Print2FlashDoc").setCurrentPage(5);
    GetDoc("Print2FlashDoc").setCurrentTool("select");
}
// -->
</script>

<body onload='setTimeout("Init()",1000);'>

Copy Code

To process a Print2Flash Document API event you need to declare a JavaScript function in the web page with the name equal to event name. Then the Print2Flash document will be sending you corresponding event by calling that function each time such an event occurs. For example, to get a notification when the current page is changed, you need to declare onPageChanged function such as in the following example:

<script language="JavaScript">
<!--
function onPageChanged(sender, page) {
    window.status="Page changed: "+page
}
// -->
</script>

Copy Code

The example above writes a new page number to the browser status window each time a current page number changes. (Note that writing to browser status window may be prohibited by your browser security settings).

The first parameter of the event handler function should be the sender parameter. It is the name of the Flash object that you used for the NAME attribute of the EMBED tag or the ID attribute of the OBJECT tag. This parameter may be helpful to differentiate between notifications generated by different documents if you have multiple documents in your movie and use a single event handler object. If you use the web page HTML code generated by Save Flash document with HTML preview page command of Print2Flash, this name is specified in the name variable in code:

var name="MyDoc"

The event handler may have additional parameters specific to each event. For example, onPageChanged event handler has a page parameter which specifies a new page number. These parameters are described in Print2Flash Document API events help topic.

See Customizing Print2Flash Document Interface sample for a more sophisticated example.

Notes:

  1. Print2Flash document API support for browsers depends on the Flash Player capabilities and is provided in the following combinations of browser and operating system:
  2. Browser Operating System
    Internet Explorer 5.0 and higher  Windows   
    Netscape 8.0 and higher  Windows   Macintosh 
    Mozilla 1.7.5 and higher  Windows   Macintosh 
    Firefox 1.0 and higher  Windows   Macintosh 
    Safari 1.3 and higher    Macintosh 
    Opera 9.01 and higher

    Windows 

     
  3. Due to Flash Player security settings Print2Flash document API may not work in browser when the HTML page is opened from local disk. You may need to upload HTML page and Print2Flash document file to a web server to use it

Resizing Print2Flash Document Published in a Web Page

The Print2Flash Document API has a function named setSize which can be used to change Print2Flash document dimensions programmatically. However, this function is available for usage only from Flash or Flex. To resize Print2Flash documents embedded in a web page you may use width and height properties of the Print2Flash document object in this way:

GetDoc("Print2FlashDoc").width=500;
GetDoc("Print2FlashDoc").height=400;  

Copy Code

Print2Flash SDK contains a sample demonstrating embedding an Flash document into a web page and using Print2Flash Document API.

 

 Copyright © Print2Flash Software 2005-2017. All rights reserved.

Support | Privacy policy