Document level JavaScript action in PDFLoadedDocument

Hi,

How can I set actions on document in PDFLoadedDocument?

In your examples, you use PDFDocument but I need set document actions in pdf file file and PdfLoadedDocument has not actions property


Thanks

3 Replies 1 reply marked as answer

GK Gowthamraj Kumar Syncfusion Team March 25, 2021 11:55 AM UTC

Hi Manolo, 
 
Thank you for contacting Syncfusion support. 
 
We do have support for adding the action in a existing PDF document in Net Core. We have created a sample to add the JavaScript Action in existing PDF document. We have attached the sample with output document for your reference. Please try the below sample on your end and let us know the result. 
 
 
Please refer the below code snippet for adding JavaScript Action in existing PDF document, 
FileStream doc = new FileStream("../../../Input.pdf", FileMode.Open, FileAccess.Read); 
//Load a PDF document. 
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(doc); 
//Add the javascript action in a pdf document. 
loadedDocument.Actions.AfterOpen = new PdfJavaScriptAction("app.alert(\"Modified Script!\")"); 
FileStream file = new FileStream("../../../Output.pdf", FileMode.Create, FileAccess.Write); 
loadedDocument.Save(file); 
loadedDocument.Close(true); 
 
Note: We are creating the UG documentation for this and we will update the details once it is reflected in live.    
 
Please let us know if you need any further assistance with this. 
 
Regards, 
Gowthamraj K 



MC Manolo Capdevila March 26, 2021 02:04 PM UTC

Thanks!

I was using older version (18.3.0.52) and it hadn't this feature.

Thanks


GK Gowthamraj Kumar Syncfusion Team March 29, 2021 11:33 AM UTC

  
Hi Manolo, 
 
Thank you for your update. 
 
We have included the feature “Support for adding JavaScript action to existing PDF document” in our Volume 4 release (18.4.0.30). Please find the download link from below, 
 
Is possible you to upgrade the Syncfusion version into latest version to get this feature “Support for adding JavaScript action to existing PDF document”? 
 
Note: We could not able to provide the patch in the product version 18.3.0.52 since it is a weekly NuGet release. If you want custom NuGet package in this version 18.3.0.52, please confirm and we can generate and share the package link in this forum itself. 
 
Regards, 
Gowthamraj K 


Marked as answer
Loader.
Up arrow icon