Skip to main content
Participant
May 22, 2023
Question

help inserting pages from an attachment

  • May 22, 2023
  • 1 reply
  • 277 views

I have a pdf that depending on user input inserts various different pages. At the moment I have all the files that are used to insert pages contained in the same folder as the original pdf and this works, however I dont want to have to accompany my pdf with an additional folder of files when I give it to other users. What I instead would like to do is attach all the extra files to the orginal pdf, however I am having trouble getting this to work.

 

I am able to open the attachments using:

 

var attachedFile = app.openDoc("|" + this.path + "|U:attached filename.pdf")

 

but it will not allow me to use the same path with insertPages ie:

 

myTrustedInsertPagesFunction(oDoc,nPage,"|" + this.path + "|U:attached filename.pdf")

also tried

myTrustedInsertPagesFunction(oDoc,nPage,attachedFile.path)

 

this gives me the following error

RaiseError: A file error has occurred.
Doc.insertPages:30:Console undefined:Exec
===> A file error has occurred.

 

anhy help or alternative methods of achieving the same result would be appreciated.

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
May 22, 2023

Use page templates instead.  

Which will also work in Reader.

 

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#template

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often