メモ
現在表示しているpdfファイルが仮に app.activeDocs[0] であるとき、app.activeDocs[0] のページに、保存済みの app.activeDocs[1] のページを透かしで追加する。
参考資料リンク
使い捨てスクリプト
// Acrobat Standard DC (2023年2月頃), Windows 11 // フォルダ : %APPDATA%\Adobe\Acrobat\Privileged\DC\JavaScripts // ファイル名: *.js // エンコード: ANSI var str = "(" + (() => { const docs = app.activeDocs; var docThis, docSrc, msg; if (docs.length != 2) { app.alert({ cMsg: "開いているPDFファイルを2つだけにしてください", cTitle: this.documentFileName }); return; } if (docs[0] === this) { docThis = docs[0]; docSrc = docs[1]; } else { docThis = docs[1]; docSrc = docs[0]; } if (docSrc.requiresFullSave) { app.alert({ cMsg: docSrc.documentFileName + " を保存してください", cTitle: docThis.documentFileName }); return; } msg = "透かしを入れますが?\r\r" + "【他に開いているページ】\r" + docSrc.documentFileName + "\r" + "ページ番号: " + (docSrc.pageNum + 1) + "\r\r" + "↓↓↓↓↓\r\r" + "【現在表示しているページ】\r" + docThis.documentFileName + "\r" + "ページ番号: " + (docThis.pageNum + 1); if (app.alert({ cMsg: msg, nIcon: 2, nType: 1, cTitle: docThis.documentFileName }) != 1) { return; } docThis.addWatermarkFromFile({ cDIPath: docSrc.path, nSourcePage: docSrc.pageNum, nStart: docThis.pageNum, nEnd: docThis.pageNum, bOnTop: true, bOnScreen: true, bOnPrint: true, nHorizAlign: app.constants.align.center, nVertAlign: app.constants.align.center, nHorizValue: 0 / 25.4 * 72, nVertValue: 0 / 25.4 * 72, bPercentage: false, nScale: 1.00, bFixedPrint: false, nRotation: 0, nOpacity: 1.00 }); }).toString() + ")();"; app.addSubMenu({ cName: "MyEditWatermark", cUser: "透かし", cParent: "Edit", nPos: 0 }); app.addMenuItem({ cName: "MyWatermark", cUser: "他に開いているページ(保存済み)を透かしで入れる", cParent: "MyEditWatermark", nPos: 0, cExec: str, cEnable: "event.rc = (event.target != null);", cMarked: "event.rc = false", bPrepend: false }); app.addMenuItem({ cName: "-", cParent: "MyEditWatermark", nPos: 1, cExec: "", bPrepend: false }); app.addMenuItem({ cName: "MyConsoleShow", cUser: "console.show()", cParent: "MyEditWatermark", nPos: 2, cExec: "console.show();", cEnable: "event.rc = true;", cMarked: "event.rc = false", bPrepend: false }); app.addMenuItem({ cName: "-", cParent: "Edit", nPos: 1, cExec: "", bPrepend: true });