d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Pdf Javascript > Replace Pages - Trustedfunction
Add Reply New Topic New Poll
Member
Posts: 1,025
Joined: Aug 17 2015
Gold: 76.22
Jul 27 2016 09:39am
Hi there,

Trying to get a button that will automatically replace a page with a specific page. Essentially going from a english statement with numbers to french statement with the same numbers in the forms.

I am getting an error when I use this code
Code
this.replacePages({
nPage: 0,
cPath:"/D:/Documents/Documents/Club Siemens/Club Siemens - Aspire Statement Re-do/Final Test - June 2016/aspireplatinumnb.pdf",
nStart: 0,
nEnd: 0
});


Error:
Code
NotAllowedError: Security settings prevent access to this property or method.
Doc.replacePages:5:Field Button4:Mouse Up


I have a folder level trusted config.js but the code in there is wrong.

version 1
Code
// Page Replacement Function
var ReplaceLastPage = app.trustedFunction( function(cPath) {
app.beginPriv();
this.replacePages(this.numPages-1, cPath); app.endPriv();
});


version 2
Code
// Page Replacement Function
var ReplaceLastPage = app.trustedFunction( function(cPath) {
cPath = cPath.replace(/([^/])$/, "$1/");
try {
app.beginPriv();
this.replacePages(this.numPages-1, cPath + "aspireplatinumnb.pdf); app.endPriv();
}
});



Any ideas or help would be appreciated!
Member
Posts: 1,025
Joined: Aug 17 2015
Gold: 76.22
Jul 28 2016 07:42am
bump
Member
Posts: 1,025
Joined: Aug 17 2015
Gold: 76.22
Jul 29 2016 08:58am
bump
Member
Posts: 1,849
Joined: May 31 2008
Gold: 2,571.50
Jul 29 2016 04:18pm
I guess I'll say it.

No need to bump. The people who go here probably check 1-7 times a week and your post will remain at the top for a good 1 month.

Also, you might have better luck posting in web languages: http://forums.d2jsp.org/forum.php?f=126

Same thing about not needing to bump there. If you do post another thread, but in the web language forum please just post a hyperlink in this thread.
Member
Posts: 1,039
Joined: Jul 8 2008
Gold: 1,939.50
Jul 29 2016 07:55pm
Quote (Noobtard @ Jul 29 2016 06:18pm)
I guess I'll say it.

No need to bump. The people who go here probably check 1-7 times a week and your post will remain at the top for a good 1 month.

Also, you might have better luck posting in web languages: http://forums.d2jsp.org/forum.php?f=126

Same thing about not needing to bump there. If you do post another thread, but in the web language forum please just post a hyperlink in this thread.


This. Javascript is a web language and this looks to be an error in configuration. The pdf which you're trying to access is probably outside of the web boundary. That means when you access the js file it can't see the file. Move the file alongside the js file as an easy fix or change your configuration so the folder the pdf is in is accessible from the web. It would be nice if you stated what server you're running / what you're serving the js files with.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll