Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Dealing with a password-protected PDF in script

Return to Member Forum

  • Author
    Posts
    • #1195443
      Brian Pifer
      Participant

      Posted this in the main Adobe forum, but no luck there so far. Was hoping someone here might be able to help me out with a problem I’m having. I am iterating through a file array and placing PDFs on new pages, and some of the files are password protected. If the user doesn’t know the password, I’d like them to be able to cancel and skip to the next file. Does anyone know how to access this part of the file through ExtendScript or a try/catch to solve for it? I have a try/catch on the frame.place() function, but that didn’t work. Below is a snippet. I am getting the following error message in debugger: (#15)Cannot execute script in target engine ‘main’! Thanks.

      for (var i = 0; i < sortedFiles.length; i++) {
      var page = doc.pages.add();
      page.appliedMaster = doc.masterSpreads.item(‘A-Master’);
      var targetFrame = page.rectangles.add({
      geometricBounds: [.9, .5, 10.5, 8],
      strokeWeight: 1,
      });
      try {
      targetFrame.place(sortedFiles[i]);
      targetFrame.fit(FitOptions.PROPORTIONALLY);
      targetFrame.fit(FitOptions.CENTER_CONTENT);
      } catch (e) {
      $.writeln(e);
      continue;
      }
      }

    • #14323746
      Brian Pifer
      Participant

      Relatedly, I just discovered that each file above is a multipage PDF. So, essentially, I am attempting to automate the placement of multiple multipage pdfs. I figure I can handle each page using PDFPlacePreference.pageNumber, but I need to know the total number of pages in each multipage PDF before doing that. I can’t seem to find where this info would be exposed though. Does anyone have any thoughts?

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Forum Ads