How would one disable Document Open JavaScript in existing PDF?
I have a population of PDFs that have the following JavaScript present which opens a Print dialog each time you open the PDF:
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//
//Document Open
//
/*********** belongs to: Document-Actions:Document Open ***********/
this.print({bUI:true,bSilent:false,bShrinkToFit:true});
//
//
These fire off whenever I load the PDF, even if I am not displaying it in PdfViewer, via
//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------
//
//
//
/*********** belongs to: Document-Actions:Document Open ***********/
this.print({bUI:true,bSilent:false,bShrinkToFit:true});
//
//
These fire off whenever I load the PDF, even if I am not displaying it in PdfViewer, via
PdfLoadedDocument sourcePDF = new PdfLoadedDocument(sourcePDFPath);
Having to manually close 300 print dialog boxes as I cycle through a batch of PDFs is very annoying for the end user.
SIGN IN To post a reply.
3 Replies
GK
Gowthamraj Kumar
Syncfusion Team
May 19, 2021 01:59 PM UTC
Hi Matthew,
Thank you for contacting Syncfusion support.
We can disable the javascript prompt while opening the PDF document in reader. For this, we have to set AfterOpen as null to PdfJavaScriptAction from the existing PDF document. Please try the below code snippet on your end and let us know the result.
|
FileStream docStream = new FileStream("../../../Input.pdf", FileMode.Open, FileAccess.ReadWrite);
PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream);
if(ldoc.Actions != null)
{
ldoc.Actions.AfterOpen = null;
}
|
Please refer the below link for more information,
If it is not suites your requirement, kindly please share the complete code snippet for PDF creation, Input document, product version to check the issue on our end. So, that it will be helpful for us to analyze and assist you further on this.
Regards,
Gowthamraj K
MP
Matthew Pierce
May 27, 2021 06:17 PM UTC
Thank you for the code snippet, unfortunately it is not working for my implementation.
PdfLoadedDocument sourcePDF = new PdfLoadedDocument(pathToPDF);
if(sourcePDF.Actions != null)
{
}
if(sourcePDF.Actions != null)
{
}
Looks like I'm missing a reference as I am getting an error with Actions: "'PdfLoadedDocument' does not contain a definition for Actions..."
Can you provide some direction? I'm using version 18.2460.0.44.
Thank you.
GK
Gowthamraj Kumar
Syncfusion Team
May 28, 2021 11:42 AM UTC
Hi Matthew,
Thank you for your update.
We have implemented the feature “Support for adding/modifying the JavaScript action in existing PDF document” only from the product version 18.4.0.30. Since you are using older version of Syncfusion assemblies (18.2460.0.44). So we request you to upgrade the Syncfusion version into latest version to get this feature.
Regards,
Gowthamraj K
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
MP Matthew Pierce
- May 18, 2021 03:49 PM UTC
- May 28, 2021 11:42 AM UTC