xlogI125’s blog

パソコン作業を効率化したい

Acrobat JavaScript練習 応急的にjpegファイルの解像度を変更する

メモ

jpegファイルの解像度を変更するための応急的な手段としてAcrobatを使用する。

  • あらかじめ「環境設定」の「PDFからの変換」で解像度などを設定しておく
  • 複数のjpegファイルに対して「ファイルをAcrobatで結合」する際の「オプション」で「常にPDFファイルにしおりを追加」を選択しておく

使い捨てスクリプト

// Acrobat Standard DC (2022年4月頃), Windows 11
// JavaScript デバッガー の コンソール から実行

(() => {
  if (this.bookmarkRoot.children.length != this.numPages) {
    console.println("// bookmarkRoot.children.length != numPages");
    return;
  } else {
    undefined;
  }

  this.bookmarkRoot.children.forEach( (bkm, i) => {
    // extractPagesを実行する前にPDFファイルを保存しておく
    const extrDoc = this.extractPages({nStart: i, nEnd: i});

    extrDoc.saveAs({
      cPath: "/C/Users/username/Desktop/tmp/" + bkm.name + ".jpg", 
      cConvID: "com.adobe.acrobat.jpeg", 
      cFS: "", bCopy: false, bPromptToOverwrite: false
    });

    extrDoc.closeDoc({bNoSave: true});

  });
})();