Problem With Javascript on PDF ! Help :)

Hi,

I have example

#Ex1:

Pdf myPdf = new Pdf();
myPdf.JavaScript = new JavaScripts();
myPdf.JavaScripts.Add("app.alert('My Test');");
myPdf.Save(@"C:\TestPdf.pdf");

When I open file TestPdf.pdf then it show alert 'MyTest' Where I found script "app.alert('My Test');" into file pdf ?

#Ex2:

FileStream fs = new FileStream(@"c:\Test1.pdf", FileMode.OpenOrCreate);
Pdf myPdf = new Pdf();
myPdf.JavaScript = new JavaScripts();
myPdf.JavaScripts.Add("app.alert('My Test');");
myPdf.Close();

I see datetime of file "Test1.pdf" it updated but when i open this file it don't show alert "My Test", why?

If I have a function " function MyFunctionTest()" added into Event of button pdf I want call it save ex over, how do i can call MyFunctionTest() of myPdf and Save and update it? :( who can help me?
=> Aspose have support for this?

1 Like

Hi,

Thank you for considering Aspose.

1. Aspose.Pdf is used to generate PDF from scratch. It does not support opening existing PDF. To edit JavaScripts in existing PDF is not supported yet.

2. Currently Aspose.Pdf support "document level" JavaScripts only. That means the JavaScripts will run when the document is opened. To add JavaScripts on button field is not supported yet. We will try to support it late but I am afraid this can't be supported in short time.

Sorry for the inconvenience.

Thank you forever ! :slight_smile:

I just research with some other component and try with “PDFKit.NET 2.0” it access with javascript very simple and use simple, It worked fine with my Apps but not free :frowning: I hope in next version of aspose will improve this problem soon :), ^^

Hi,

Thanks for your suggestion. We have added this into our plan.