• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

PDFOpenOptions and number of pages in PDF being opened

New Here ,
Nov 21, 2022 Nov 21, 2022

Copy link to clipboard

Copied

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

TOPICS
Actions and scripting

Views

126

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Nov 21, 2022 Nov 21, 2022

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines