Skip to main content
Participant
June 15, 2023
Question

Invalid arguments on Doc.insertPages - Acrobat SDK

  • June 15, 2023
  • 2 replies
  • 751 views

I'm trying to insert a page into an attachment of a PDF. I have a main pdf file called "Ctrl.pdf" that has several attachments. Inside a Trusted Function called via button in "Ctrl.pdf" I get the Doc of the attachment:

 

att = this.openDataObject("myAttachment.pdf");

 

 
Then I try to insert a page to that attachment:

 

att.insertPages ({
    nPage: 0,
    cPath: "/c/new-pages.pdf",
    nStart: 0
});

 

 
But get the following error: 
InvalidArgsError: Invalid arguments.
Doc.insertPages
I dont see how the arguments are wrong, I'm sure the location is correct, also tryed with relative path but nothing changed.
This topic has been closed for replies.

2 replies

Bernd Alheit
Community Expert
Community Expert
June 16, 2023

Try this :

Put the file in a folder of the C drive

E.g. /C/temp/...

try67
Community Expert
Community Expert
June 16, 2023

I thought that might be the case, too, but it doesn't seem to be. It seems some types of editing of the attached document are allowed, and others are not... It's very odd. It might have to do with the fact that it is opened as a hidden document, instead of being displayed on the screen. For example, I was able to modify the file's metadata using a similar code, but not the pages in it.

kglad
Community Expert
Community Expert
June 15, 2023

in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

 

p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post if it helps you get responses.

 

<moved from using the community>