Skip to main content
Participant
November 21, 2022
Frage

PDFOpenOptions and number of pages in PDF being opened

  • November 21, 2022
  • 1 Antwort
  • 355 Ansichten

Hi there,

I'm currently writing a script (JS) that is to take each page of a PDF document, resize it to predetermined pixel sizes, in different documentModes, in a loop such that PDFOpenOptions.page is equal to a counter starting 1 and keeps going.  Is there a object or whatever that tells you the number of pages in the whole document?  I figure there must be, since when you open a multipage PDF in Photoshop, it presents the dialog box that shows the total number of pages and allows you to choose X number of total pages.  I'd then do the resizing, etc. in a while loop, less than said number plus 1 or something.  The script halts after the last page in the PDF document is processed and then Photoshop presents that dialog box to choose the page from the PDF.

 

If there isn't such a convenient way of achieving this, is there another method or crude hack to end the script?

 

Thanks, Paul

Dieses Thema wurde für Antworten geschlossen.

1 Antwort

Legend
November 21, 2022

Hello @PWMarkowski,

 

This is what I use to open all the pages in a given pdf....

      app.displayDialogs = DialogModes.NO;
   
        var check = true;
        var page = 1;
            
        var pdfOpenOpts = new PDFOpenOptions;
            pdfOpenOpts.antiAlias = true;
            pdfOpenOpts.bitsPerChannel = BitsPerChannelType.EIGHT;
            pdfOpenOpts.cropPage = CropToType.MEDIABOX;
            pdfOpenOpts.mode = OpenDocumentMode.CMYK;
            pdfOpenOpts.resolution = 600;
            pdfOpenOpts.suppressWarnings = true;
            pdfOpenOpts.usePageNumber = true;
                      
     while (check == true) {
        try { pdfOpenOpts.page = page;
        app.open(openSomeFile, pdfOpenOpts);
        
       page++;
       } catch (e) {
       check = false
      }
   }

Regards,

Mike