Adding Javascript to Push Button

Hi Team,

Im trying to add a push button into a PDF and then adding javascript to the push button field which open the print pop up on click. But the javascript is not working.

The code which i tried:

Aspose.Pdf.Document d = new Aspose.Pdf.Document(app_path + "Popup.pdf");

Aspose.Pdf.Facades.

FormEditor frm = new Aspose.Pdf.Facades.FormEditor(d);

frm.AddField(Aspose.Pdf.Facades.

FieldType.PushButton, "Print", "Printing", 1, 200, 700, 300, 725);

frm.SetFieldAppearance(

"Print", Aspose.Pdf.InteractiveFeatures.Annotations.AnnotationFlags.Print);

frm.SetFieldScript(

"Print", "window.print();");

frm.Save(ms);

Also find attached the PDF on which i applied this field and javascipt. Kindly help me on this issue.

Hi Santosh,

Thanks for your inquiry. Please use the following script instead window.print(), it will resolve the issue.

frm.SetFieldScript(“Print”,“var pp = this.getPrintParams(); this.print(pp);”);

Please feel free to contact us for any further assistance.

Best Regards,

Thanks team, I also have another request. How to bind ajax calls script to the same push button field. I tried the following code

$.ajax({

type:

"POST",

url:

"Demo.aspx/Method",

contentType:

"application/json; charset=utf-8",

dataType:

"json",

success: OnSuccess,

failure:

function (response) {

/*some text*/

},

error:

function (response) {

/*some text*/}

});

But this is not working. Kindly help us on how to make ajax calls from push button field click

Hi Santosh,


Thanks for your inquiry. We are looking into your requirements and will get back to you soon.

Best Regards,

Hi Santosh,


Thanks for your inquiry. I am afraid the ajax script is not supported at the moment. So we have logged a new feature request for same as PDFNEWNET-37965 in our issue tracking system for further investigation and implementation. We will notify you as soon as we implement it.

We are sorry for the inconvenience caused.

Best Regards,