Hi,
When I use PDF-XChange Viewer SDK via C# for export pdf to image, SDK seems to be running JavaScript by default including it in PDF.
I'd like to disable JavaScript in Program. What IPDFXCview interface should I use?
PDFXCview version is 2.5.203.0.
Best regards,
How to disable JavaScript by C#
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am
Re: How to disable JavaScript by C#
Hello ys group,
I am not sure I fully understand the situation. Is there some JS embedded in the file that you want to prevent from running?
Can you provide a sample and instructions how to reproduce the behaviour you are observing now, and a more detailed explanation of what you want to achieve?
Regards,
Stefan
I am not sure I fully understand the situation. Is there some JS embedded in the file that you want to prevent from running?
Can you provide a sample and instructions how to reproduce the behaviour you are observing now, and a more detailed explanation of what you want to achieve?
Regards,
Stefan
-
- User
- Posts: 5
- Joined: Mon Jul 02, 2012 6:30 am
Re: How to disable JavaScript by C#
Hello stefan,
I provide sample code and pdfs.
Note:
1) Please download zipfile and unzip under C Drive. You can see C:\demoproj folder.
2) C:\demoproj\JS.pdf is including Javascript. NoJS.pdf is not including Javascript.
3) If you run C:\demoproj\TestForNoJS.cmd, exe reads NoJS.pdf without window and outputs png image to C:\demoproj\dst folder automatically.
Finally, program will exit without stop.
4) If you run C:\demoproj\TestForJS.cmd, exe reads JS.pdf and outputs png image same destination.
But when exe closes the document, the viewer runs Javascript and you can see alert popup window 'hello!!'.
To export image automatically, I'd like to disable running Javascript on the viewer.
Thanks,
I provide sample code and pdfs.
Note:
1) Please download zipfile and unzip under C Drive. You can see C:\demoproj folder.
2) C:\demoproj\JS.pdf is including Javascript. NoJS.pdf is not including Javascript.
3) If you run C:\demoproj\TestForNoJS.cmd, exe reads NoJS.pdf without window and outputs png image to C:\demoproj\dst folder automatically.
Finally, program will exit without stop.
4) If you run C:\demoproj\TestForJS.cmd, exe reads JS.pdf and outputs png image same destination.
But when exe closes the document, the viewer runs Javascript and you can see alert popup window 'hello!!'.
To export image automatically, I'd like to disable running Javascript on the viewer.
Thanks,
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am
Re: How to disable JavaScript by C#
Hi ys group,
I could not find an option to turn off JS execution via code, so what I could think of is to e.g. make this change in an end user instance of the Viewer then export the settings from the end user viewer to a data file. You can then use this data file and LoadSettings() to apply that settings file to the AX.
Or alternatively - you can just suppress all display prompts capturing the OnDisplayPrompt notification and supplying a custom UserChouse value.
Regards,
Stefan
I could not find an option to turn off JS execution via code, so what I could think of is to e.g. make this change in an end user instance of the Viewer then export the settings from the end user viewer to a data file. You can then use this data file and LoadSettings() to apply that settings file to the AX.
Or alternatively - you can just suppress all display prompts capturing the OnDisplayPrompt notification and supplying a custom UserChouse value.
Regards,
Stefan
-
- User
- Posts: 5
- Joined: Mon Jul 02, 2012 6:30 am
Re: How to disable JavaScript by C#
Hi Stefan,
Thank you for your reply.
First, I show user viewer and turn off 'Enable JavaScript Actions' from Preferences menu and output dat file by 'Export All Settings to Data File'.
And my program reads dat file by LoadSettings method and exports Image.
I could suppress running Javascript.
Best regards,
Thank you for your reply.
First, I show user viewer and turn off 'Enable JavaScript Actions' from Preferences menu and output dat file by 'Export All Settings to Data File'.
And my program reads dat file by LoadSettings method and exports Image.
I could suppress running Javascript.

Best regards,
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am
Re: How to disable JavaScript by C#
Glad to help ys group!
Cheers,
Stefan
Cheers,
Stefan
-
- Site Admin
- Posts: 2445
- Joined: Thu Jun 30, 2005 4:11 pm
Re: How to disable JavaScript by C#
Hi, ys group.
Try to use:
HTH
Try to use:
Code: Select all
pdfViewer.SetProperty("JavaScript.Enable", "false", 0);
PDF-XChange Co. LTD (Project Developer)
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 5
- Joined: Mon Jul 02, 2012 6:30 am
Re: How to disable JavaScript by C#
Hi Vasyl,
I try to use your code, I can suppress running Javascript.
Thanks,
I try to use your code, I can suppress running Javascript.
Thanks,
-
- Site Admin
- Posts: 19868
- Joined: Mon Jan 12, 2009 8:07 am