Acrobat Javascript
Copy link to clipboard
Copied
importDataObject (to attach a pdf file) is not working in Acrobat DC. Also not throwing any errors. I got strucked in that. Someone help me. I need a javascript code to attach a pdf file inside a main pdf file.
Note: importDataObject is woking fine in "Adobe Acrobat X Standard", but not working in "Acrobat DC Pro". Is this a bug in Adobe Javascript?
My Code is - - this.importDataObject("Checklist", Checklist_Path);
Checklist_Path is a variable having the pdf file path with forward slashes.
Help appriciated. Thanks.
Copy link to clipboard
Copied
Where is the code located?
Copy link to clipboard
Copied
The code is located in server "C:\Program Files\Adobe\Acrobat DC\Acrobat\Javascripts"
Copy link to clipboard
Copied
That's not enough. You have to run it from a trusted function. See:
https://acrobatusers.com/tutorials/trust-and-privilege-in-acrobat-scripts
https://acrobatusers.com/tutorials/using_trusted_functions
And if you check the JS Console you should see an error message regarding it.
Copy link to clipboard
Copied
Here is my entire code:
var attachPreparerChecklist = app.trustedFunction( function()
{
app.beginPriv();
var preparerChecklist_Path = global.checkListBase_Path + "2022 Preparer Checklist.pdf";
(global.lastDoc).importDataObject("Preparer Checklist", preparerChecklist_Path);
app.alert("\nPreparer Checklist is Attached Successfully", 1, 0, "Preparer Checklist Attachment");
app.endPriv();
});
It is showing the successful alert. But not attaching the checklist.
(global.lastDoc) is nothing but "this".
I tried attaching the checklist pdf manually once and then that plugin is working. After closing and opening the acrobat dc pro then it is not woking. Sooooo weird. I am totally confused.
Copy link to clipboard
Copied
No error is showing in the Console. That is the problem. Is there any setting that I have to do with Adobe Acobat DC Pro version to attach the checklist pdf?
Copy link to clipboard
Copied
In the future please post the actual code you're using, not something similar. The devil is in the details...
First of all, you should check the return value of imprtDataObject. It returns true if successful, or throws an exception on failure. So there has to be an error in the JS Console, unless you caught it and didn't handle it properly.
Also, instead of using a global variable, I would pass a reference to the Document object to the function as a parameter. Same for the path to the file you want to attach. Do that and see if it helps solve the issue.
Copy link to clipboard
Copied
It is showing true.
Now I changed the code to,
var attachPreparerChecklist = app.trustedFunction( function()
{
app.beginPriv();
var rtn = (global.lastDoc).importDataObject("Preparer Checklist", "/wlt-data-1/Adobe/AdobeAutomationDontDelete/04_ChecklistBase/2022 Preparer Checklist.pdf");
app.alert(rtn); // here it is showing true
app.alert("\nPreparer Checklist is Attached Successfully", 1, 0, "Preparer Checklist Attachment");
app.endPriv();
});
But still not working.
Copy link to clipboard
Copied
This is the exact path of the checklist "/wlt-data-1/Adobe/AdobeAutomationDontDelete/04_ChecklistBase/2022 Preparer Checklist.pdf"
Copy link to clipboard
Copied
You didn't implement the first change I recommended, ie. passing a reference to the Doc object as a parameter, instead of using a global variable.
Copy link to clipboard
Copied
Please provide me a sample code. Thanks.
Copy link to clipboard
Copied
This is intolerably rude. See https://community.adobe.com/t5/acrobat-discussions/attach-pdf-in-to-a-pdf-using-javascript-sample-co...
Please do NOT ask for sample code, minutes after you have been asked not to ask for sample code, imagining we don't read the other posts. So rude!
Please do NOT start new discussions, without linking to the old one.
Please do NOT register new users to make it look like a new discussion.
Or, please NEVER allow multiple members of the same team to start the same discussion separately.

