My pluggin is not working anymore with last update
Moderators: Tracker Support, TrackerSupp-Daniel, Sean - Tracker, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Ivan - Tracker Software, Tracker Supp-Stefan
My pluggin is not working anymore with last update
Hello.
I developed a plugin where I can extract and create a new file PDF considering a word founded but with last update is not working anymore.
Can anyone help me? Thanks
I developed a plugin where I can extract and create a new file PDF considering a word founded but with last update is not working anymore.
Can anyone help me? Thanks
- Tracker Supp-Stefan
- Site Admin
- Posts: 18770
- Joined: Mon Jan 12, 2009 8:07 am
- Contact:
Re: My pluggin is not working anymore with last update
Hello nbmani,
Most likely some of the methods you are using require elevated privileges (and we were not enforcing those correctly in the past).
You will likely need to create trustedFunction in which to execute your code and it will work once again.
Please take a look e.g. here on how to declare such a trusted function:
viewtopic.php?p=170799#p170799
Kind regards,
Stefan
Most likely some of the methods you are using require elevated privileges (and we were not enforcing those correctly in the past).
You will likely need to create trustedFunction in which to execute your code and it will work once again.
Please take a look e.g. here on how to declare such a trusted function:
viewtopic.php?p=170799#p170799
Kind regards,
Stefan
Re: My pluggin is not working anymore with last update
I tried to do what you suggested but still having the same error: "Security prevents to use this object.."
- TrackerSupp-Daniel
- Site Admin
- Posts: 9585
- Joined: Wed Jan 03, 2018 6:52 pm
Re: My pluggin is not working anymore with last update
Hello, nbmani
Would it be possible for you to send us a sample of your plugin, so that we can have the dev team take a look at see what it may be?
Kind regards,
Would it be possible for you to send us a sample of your plugin, so that we can have the dev team take a look at see what it may be?
Kind regards,
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Re: My pluggin is not working anymore with last update
Sure.
Where should I send a sample?
Where should I send a sample?
- Tracker Supp-Stefan
- Site Admin
- Posts: 18770
- Joined: Mon Jan 12, 2009 8:07 am
- Contact:
Re: My pluggin is not working anymore with last update
Hello nbmani,
Please e-mail that to support@pdf-xchange.com with a link back to this topic also included in the mail, and we would be happy to take a look for you!
Kind regards,
Stefan
Please e-mail that to support@pdf-xchange.com with a link back to this topic also included in the mail, and we would be happy to take a look for you!
Kind regards,
Stefan
Re: My pluggin is not working anymore with last update
Thank you, already sent a sample.
Thank you for your help
Thank you for your help
- Tracker Supp-Stefan
- Site Admin
- Posts: 18770
- Joined: Mon Jan 12, 2009 8:07 am
- Contact:
Re: My pluggin is not working anymore with last update
Hello nbmani,
Thanks! We got your sample code, and will ask one of our colleagues from the dev team to take a look. We will post an update as soon as we have any additional news!
Kind regards,
Stefan
Thanks! We got your sample code, and will ask one of our colleagues from the dev team to take a look. We will post an update as soon as we have any additional news!
Kind regards,
Stefan
Re: My pluggin is not working anymore with last update
Hi.
I did not receive any feedback so I tried to do on my own. I have the version 10.2.1.385 and still having having the same error "An error occured: NotAllowedError: Security settings prevent access to this property or method."
What I'm doing wrong?
I did not receive any feedback so I tried to do on my own. I have the version 10.2.1.385 and still having having the same error "An error occured: NotAllowedError: Security settings prevent access to this property or method."
What I'm doing wrong?
Code: Select all
app.addToolButton({
cName: "ExtractPagesByKeywords",
cLabel: "Extract Pages by Keywords to one PDF file",
cExec: "extractPagesByKeywords()",
cTooltext: "Extract pages containing specific keywords",
cEnable: true,
nPos: -1
});
var extractPagesByKeywords = app.trustedFunction(function () {
app.beginPriv();
try {
var doc = this;
var searchText = app.trustedFunction(function () {
app.beginPriv();
var result = app.response("Enter the text to search for (not case sensitive), separated by commas:");
app.endPriv();
return result;
})();
if (!searchText) {
app.alert("No keyword(s) inserted.");
return;
}
var searchTextGroups = searchText.split(",").map(app.trustedFunction(function (group) {
app.beginPriv();
var result = group.trim().split(" ");
app.endPriv();
return result;
}));
var searchResults = new Set();
for (var i = 0; i < doc.numPages; i++) {
app.beginPriv(); // Start of the privileged section for the loop
var numWords = doc.getPageNumWords(i);
var pageText = "";
for (var j = 0; j < numWords; j++) {
var word = doc.getPageNthWord(i, j, true);
pageText += word + " ";
}
app.endPriv(); // End of the privileged section for the loop
searchTextGroups.forEach(app.trustedFunction(function (group) {
app.beginPriv();
var groupFound = group.every(function (keyword) {
return pageText.toLowerCase().includes(keyword.toLowerCase());
});
if (groupFound) {
searchResults.add(i);
}
app.endPriv();
}));
}
if (searchResults.size > 0) {
app.beginPriv();
var outputPath = doc.path.replace(/\.pdf$/, '_' + 'extracted' + '.pdf');
var newDoc = app.newDoc();
searchResults.forEach(app.trustedFunction(function (pageIndex) {
app.beginPriv();
newDoc.insertPages({
nPage: newDoc.numPages - 1,
cPath: doc.path,
nStart: pageIndex,
nEnd: pageIndex
});
app.endPriv();
}));
newDoc.deletePages(0);
newDoc.saveAs(outputPath);
newDoc.closeDoc(true);
app.endPriv();
console.println("Pages extracted and saved to file: " + outputPath);
app.alert("Process concluded. The pages were extracted and saved in the same folder as the original file: " + outputPath, 3);
} else {
console.println("Text not found.");
app.alert("None of the words entered were found in the document.");
}
} catch (e) {
console.println("An error occurred: " + e);
app.alert("An error occurred: " + e);
}
app.endPriv();
});
- Roman - Tracker Supp
- Site Admin
- Posts: 317
- Joined: Sun Nov 21, 2004 3:19 pm
Re: My pluggin is not working anymore with last update
Hi nbmani,
Please try this one:
Please try this one:
Code: Select all
app.addToolButton({
cName: "ExtractPagesByKeywords",
cLabel: "Extract Pages by Keywords to one PDF file",
cExec: "extractPagesByKeywords()",
cTooltext: "Extract pages containing specific keywords",
cEnable: true,
nPos: -1
});
var extractPagesByKeywords = app.trustedFunction(function () {
try {
var doc = this;
app.beginPriv();
var searchText = app.response("Enter the text to search for (not case sensitive), separated by commas:");
app.endPriv();
if (!searchText) {
app.alert("No keyword(s) inserted.");
return;
}
var searchTextGroups = searchText.split(",").map(group => group.trim().split(" "));
var searchResults = new Set();
for (var i = 0; i < doc.numPages; i++) {
var numWords = doc.getPageNumWords(i);
var pageText = "";
for (var j = 0; j < numWords; j++) {
var word = doc.getPageNthWord(i, j, true);
pageText += word + " ";
}
searchTextGroups.forEach(function (group) {
var groupFound = group.every(function (keyword) {
return pageText.toLowerCase().includes(keyword.toLowerCase());
});
if (groupFound) {
searchResults.add(i);
}
});
}
if (searchResults.size > 0) {
var outputPath = doc.path.replace(/\.pdf$/, '_' + 'extracted' + '.pdf');
app.beginPriv();
var newDoc = app.newDoc();
for (const pageIndex of searchResults) {
newDoc.insertPages({
nPage: newDoc.numPages - 1,
cPath: doc.path,
nStart: pageIndex,
nEnd: pageIndex
});
}
newDoc.deletePages(0);
newDoc.saveAs(outputPath);
app.endPriv();
newDoc.closeDoc(true);
console.println("Pages extracted and saved to file: " + outputPath);
app.alert("Process concluded. The pages were extracted and saved in the same folder as the original file: " + outputPath, 3);
} else {
console.println("Text not found.");
app.alert("None of the words entered were found in the document.");
}
} catch (e) {
console.println("An error occurred: " + e);
app.alert("An error occurred: " + e);
}
});
Re: My pluggin is not working anymore with last update
It worked!! Many thanks!!!
- TrackerSupp-Daniel
- Site Admin
- Posts: 9585
- Joined: Wed Jan 03, 2018 6:52 pm
My pluggin is not working anymore with last update
Dan McIntyre - Support Technician
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
Tracker Software Products (Canada) LTD
+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com