- 内容
- 選択された注釈のプロパティをコンソールに表示
- 全ページの回転とページサイズをコンソールに表示
- しおりの移動先ページ番号をコンソールに表示
- テスト環境
- 保存先フォルダ
%APPDATA%\Adobe\Acrobat\Privileged\DC\JavaScripts
- 保存先ファイル名
- エンコード
console.show();
console.println('\
\r\
');
app.addMenuItem({cName: "-", cParent: "Help", cExec: "", bPrepend: false});
app.addSubMenu({cName: "testSubMenu", cUser: "テスト", cParent: "Help"});
app.addMenuItem({
cName: "test0", cUser: "コンソールを表示(&J)", cParent: "testSubMenu",
cExec: "(() => { console.clear(); console.show(); })();",
cEnable: "event.rc = true;", bPrepend: false
});
app.addMenuItem({cName: "-", cParent: "testSubMenu", cExec: "", bPrepend: false});
(function() {
const f = (() => {
const doc = this;
const annots = doc.selectedAnnots;
console.clear();
console.show();
if (annots === undefined) {
console.println("// 注釈が選択されていません");
return;
}
annots.forEach((annot, i) => {
var propname, str = "";
str += util.printf("%d/%d ... %s\r", i + 1, annots.length, annot["type"]);
str += util.printf("----------------------------------------\r");
for (propname in annot.getProps()) {
str += util.printf("%s: %s\r", propname, annot[propname]);
}
str += util.printf("----------------------------------------\r");
str += util.printf('// this.getAnnot(%d, "%s").setProps({author: "", subject: ""});\r\r', annot.page, annot.name);
console.println(str);
});
});
const str = util.printf("(%s)();", f.toString());
app.addMenuItem({
cName: "test1",
cUser: "選択された注釈のプロパティをコンソールに表示(&K)",
cParent: "testSubMenu",
cExec: str, cEnable: "event.rc = (event.target != null);", bPrepend: false
});
})();
app.addMenuItem({cName: "-", cParent: "testSubMenu", cExec: "", bPrepend: false});
(function() {
const f = (() => {
const doc = this, arrStr = new Array();
var rot, x0mm, y0mm, x1mm, y1mm, str = "";
arrStr.push(util.printf("page | rot | wC[mm], hC[mm] | wM[mm], hM[mm] | wA[mm], hA[mm] | wT[mm], hT[mm] | wB[mm], hB[mm]\r"));
for (var pageNum = 0; pageNum < doc.numPages; pageNum++) {
rot = doc.getPageRotation({nPage: pageNum});
str += util.printf("%4d | %3d | ", pageNum + 1, rot);
[x0mm, y1mm, x1mm, y0mm] = doc.getPageBox({cBox: "Crop", nPage: pageNum}).map(x => x * 25.4 / 72);
str += util.printf("%3.2f, %3.2f | ", x1mm - x0mm, y1mm - y0mm);
[x0mm, y1mm, x1mm, y0mm] = doc.getPageBox({cBox: "Media", nPage: pageNum}).map(x => x * 25.4 / 72);
str += util.printf("%3.2f, %3.2f | ", x1mm - x0mm, y1mm - y0mm);
[x0mm, y1mm, x1mm, y0mm] = doc.getPageBox({cBox: "Art", nPage: pageNum}).map(x => x * 25.4 / 72);
str += util.printf("%3.2f, %3.2f | ", x1mm - x0mm, y1mm - y0mm);
[x0mm, y1mm, x1mm, y0mm] = doc.getPageBox({cBox: "Trim", nPage: pageNum}).map(x => x * 25.4 / 72);
str += util.printf("%3.2f, %3.2f | ", x1mm - x0mm, y1mm - y0mm);
[x0mm, y1mm, x1mm, y0mm] = doc.getPageBox({cBox: "Bleed", nPage: pageNum}).map(x => x * 25.4 / 72);
str += util.printf("%3.2f, %3.2f\r", x1mm - x0mm, y1mm - y0mm);
if ((pageNum + 1) % 250 == 0 || (pageNum + 1) == doc.numPages) {
arrStr.push(str);
str = "";
}
}
console.clear();
console.show();
arrStr.forEach(s => console.println(s));
});
const str = util.printf("(%s)();", f.toString());
app.addMenuItem({
cName: "test2",
cUser: "全ページの回転とページサイズをコンソールに表示(&L)",
cParent: "testSubMenu",
cExec: str, cEnable: "event.rc = (event.target != null);", bPrepend: false
});
})();
app.addMenuItem({cName: "-", cParent: "testSubMenu", cExec: "", bPrepend: false});
(function() {
const f = (() => {
const doc = this;
var str = "lv | page | name\r";
const func = ((lv, bkm) => {
var pageNumBefore;
if (lv == 0 && bkm.children == null) {
str = "// しおりが存在しません";
return;
}
if (lv != 0) {
pageNumBefore = doc.pageNum;
doc.pageNum = 0;
bkm.execute();
str += util.printf("%2d | %4d | %s\r", lv, doc.pageNum + 1, "|".repeat(lv - 1) + bkm.name);
doc.pageNum = pageNumBefore;
}
if (bkm.children != null) {
for (var i = 0; i < bkm.children.length; i++) {
func(lv + 1, bkm.children[i]);
}
}
});
func(0, doc.bookmarkRoot);
console.clear();
console.show();
console.println(str);
});
const str = util.printf("(%s)();", f.toString());
app.addMenuItem({
cName: "test3",
cUser: "しおりの移動先ページ番号をコンソールに表示(&M)",
cParent: "testSubMenu",
cExec: str, cEnable: "event.rc = (event.target != null);", bPrepend: false
});
})();