Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support


All forums · Statistics · Search ·

Two Pilots forum / For software developers / Javascript Problem
Author Message
Anonymous
# Posted: 15 Jun 2005 14:05


Hello,

As you suggest me in "Create Submit Button? " Topic that I can add javascript in PDF file .And now I used createjavacriptaction property in C++ :

PDF->CreateJavacriptAction ("window.print()");

It has an error in acrobat program :
Acrobat EScript Built-in Functions Version 5.0
Acrobat Annotations / Collaboration Built-in Functions Version 5.0
Acrobat Database Connectivity Built-in Functions Version 5.0

ReferenceError: window is not defined

What 's wrong?

Jan

Stanislav
# Posted: 15 Jun 2005 15:26


Dear Jan,

Can you send us your code using our support form ?
This may help to find a solution.

Thank you very much !

Best regards,
Stanislav

Anonymous
# Posted: 16 Jun 2005 06:28


Sawasdee(Hello) Stanislav,

Try 1 :
PDF->PDFPAGE_CreateControl_Button("Btn1",480,580,400,500);
PDF->PDFANNOTATION_Caption = "Print";
PDF->PDFANNOTATION_OnMouseUp = PDF->CreateJavascriptAction("javascript:window.print()");

Try 2 :
PDF->PDFPAGE_CreateControl_Button("Btn1",480,580,400,500);
PDF->PDFANNOTATION_Caption = "Print";
PDF->PDFANNOTATION_OnMouseUp = PDF->CreateJavascriptAction("window.print()");

Thanks,
Jan

Anonymous
# Posted: 16 Jun 2005 06:53


Is it possible to has "window.close()" and "window.print()" together in one syntax(CreateJavascriptAction property) ? Because I have to do it!

Thanks,
Jan.

Stanislav
# Posted: 16 Jun 2005 14:03


Dear Jan,

Yes, it's possible.

I recommend you to download JavaScript Object Specification here:
http://www.planetpdf.com/codecuts/pdfs/tutorial/AcroJS.pdf
because it contains complete description of the PDF JavaScript.

The methods you used are incorrect: window.print(), window.close(). There is no such methods in the Acrobat object. Here is the working example:

Set PDF = CreateObject("PDFCreatorPilot2.piPDFDocument")

PDF.StartEngine "demo@demo","demo"
PDF.DocumentInfo_CreationDate = Now
PDF.Filename = "JSActions.pdf"
PDF.DocumentInfo_Title = "Java Script Actions example"
PDF.AutoLaunch = true
PDF.COmpression = 1 ' 1 = ctFlate

PDF.BeginDoc

Btn1 = PDF.PDFPAGE_CreateControl_Button ("test", 20, 90, 65, 105)
' current annotation is the last created control or annotation, i.e. button
PDF.PDFANNOTATION_Caption = "Test"
JSAct = PDF.CreateJavaScriptAction("this.print();this.closeDoc();")
PDF.PDFANNOTATION_OnMouseUp = JSAct

PDF.EndDoc

Thank you very much !

Best regards,
Stanislav

 

 

Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.013

 

Page top