mirta mirta - 7 months ago 81
Javascript Question

Insert an image into pdf (Adobe Acrobat Pro) using javascript

This is what I want to do:

.this.getField('imageField').importImage('path_to_img');


I know this code is not correct, but is there a way to do this? I couldn't find the solution in Acrobat's documentation.

I need to do it using javascript because
path_to_image
is a variable I'm pulling from a database...

Answer

I got an anwser on Adobe forums. Here is the full discussion: https://forums.adobe.com/message/8694023#8694023

var f = this.getField("btnImage");
f.buttonSetCaption("Title");
  if (f.buttonImportIcon("/C/image.pdf") == 0){  // if 0 == no error
      f.buttonImportIcon("/C/image.pdf");
  }

Also when you are setting a button you have to select an option "Icon only" for this to work.