These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Java script printing issue

Sadhasivam
Registered: Nov 10 2008
Posts: 4

The following java script function

function callme()
{
var status = 0;
var AccroApp;
var p;
var a;
var i;
// alert(PrintString );
//alert(printpage);
alert("hai");
try
{
AcroApp = new ActiveXObject('AcroExch.App');
p = new ActiveXObject('AcroExch.PDDoc');
a = new ActiveXObject('AcroExch.AvDoc');
p.Open("c:\abcd.pdf");
a = p.OpenAVDoc(p.GetFileName);
i = p.GetNumPages

a.PrintPagesSilent(1,i,0,0,0);

a.Close(0); // 'close with same name as when opened
p.Close;
AcroApp.Exit;

}
catch (e)
{

if (e.number != 0)
{
alert("Unable to Print - " + e.description);

}
}

}

when this function is called, I am getting an error message when the state a.PrintPagesSilent(1,i,0,0,0); is executed stating that "method is not supported"

I am using Adobe 7.0 Standard edition. Please help me in resolving this issue.

with regards,

Sadhasivam S

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
And is this JavaScript being executed within a PDF or is it external to Acrobat?

Within Acrobat JavaScript there is no "PrintPagesSilent(1,i,0,0,0); " function. Does you applicaton, Acrobat, folder level JavaScript folder contain the code for a custom function called "PrintPageSilent"?

You can call the doc object's "print()" funciton to print a page when you provide the appropriate parameters for the user interface display, the start page, the end page, and silent operation. There are also ohter optional parameters that can be used.

George Kaiser

Sadhasivam
Registered: Nov 10 2008
Posts: 4
Hi George,

Thanks for your response.

The script is called in an external web application (aspx page). But this function is called at the browser level (client script).

PrintPagesSilent is not the method we have written it was available in Acrobat 6.0 version. This method is not supported in 7.0 or higher.

This method was used to print the selected pages from the pdf document. Please let me know if there is any equivalent method for the same is available in 7.0 or higher. Examples or syntax of the function will be appreciated.

with thanks,

Sadhasivam S
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Well, I did not see it in any of the Acrobat JavaScirpt Reference manuals for versions 4 thru 8. But the interactive constant was add with the 'printParam" object in version 6 and degraded by adding security restrictions in version 7, but this can be worked around by using the trusted function.

One can use the "print()" method as:

// print a file silently
this.print({bUI: false, bSilent: true, nStart:0, nEnd: i - 1, bSilent: true});

bUI: logical to hide User Interface
nStart: zero based page number to start printing at
nEnc: zero based page number to end printing
bSilent: suppress the cancel dialog

Then there is the "PrintParams" object for the "print" method:

// get the printParams object of the default printer
var pp = this.getPrintParams();
// set some properties
pp.firstPage = 0; // zero based start page
pp.lastPage = i - 1; // zero based end page
pp.interactive = pp.constants.interactionLevel.silent; // silent - no UI no progess
// print
this.print(pp); // print using the set print parameters

You may need to modify some to the syntax for the external API calls.

For any web application I would consider only using the "print" method and avoid the "printParams" because of its restrictions and there are many users still on versions prior to version 6.

Since you are printing all the pages, there is no need to specify the start and end pages, this is the default.

George Kaiser