ページサイズを表示
- PageRotationと各種のBoxサイズをReportで表示する
(() => {
var rep = new Report();
rep.size = 1.5;
const doc = this;
const numPages = doc.numPages;
[...Array(numPages)].forEach( (_null, pageNum) => {
rep.color = ["RGB", 0/255, 0/255, 0/255];
rep.writeText("path: " + doc.path);
rep.color = ["RGB", 0/255, 128/255, 192/255];
rep.writeText("pageNum: " + pageNum);
rep.color = ["RGB", 192/255, 128/255, 0/255];
rep.writeText("PageRotation: " + doc.getPageRotation({nPage: pageNum}));
["Media", "Bleed", "Trim", "Art", "Crop", "BBox"].forEach( box => {
const [x1, y2, x2, y1] = doc.getPageBox({
cBox: box, nPage: pageNum
}).map( x => (25.4 / 72) * x );
switch (box) {
case "Media":
rep.color = ["RGB", 0/255, 0/255, 0/255];
break;
case "Bleed":
rep.color = ["RGB", 0/255, 0/255, 192/255];
break;
case "Trim":
rep.color = ["RGB", 0/255, 128/255, 0/255];
break;
case "Art":
rep.color = ["RGB", 192/255, 0/255, 0/255];
break;
case "Crop":
rep.color = ["RGB", 0/255, 0/255, 0/255];
break;
case "BBox":
rep.color = ["RGB", 0/255, 0/255, 0/255];
break;
default:
rep.color = ["RGB", 0/255, 0/255, 0/255];
}
rep.writeText(util.printf(
"%s: \r[%.3f, %.3f], [%.3f, %.3f]", box, x1, y1, x2, y2
));
});
rep.divide();
});
const docRep = rep.open("レポート.pdf");
})();
ページの差し込み
- 新版PDF(docNew)のページ順序を 12345 とし、旧版PDF(docOld)のページ順序を ABCDE とする。
- docNew に docOld を差し込んで 1A2B3C4D5E とする。
(() => {
const docNew = this;
const numPages = docNew.numPages;
[...Array(numPages)].forEach( (_null, i) => {
docNew.insertPages({
nPage: 2 * i,
cPath: "/C/Users/username/Desktop/旧版.pdf",
nStart: i, nEnd: i
});
});
})();
用紙サイズを既存PDFに合わせて内容を透かしで入れる
- 新規にPDFを作成し、既に保存されているPDFファイルに用紙サイズを合わせ、内容を透かしで入れる。
- 既に保存されているPDFファイルで ArtBox は適切に設定されているものとします。
(() => {
const numPages = this.numPages;
const docNew = app.newDoc({
nWidth: Math.round((72 / 25.4) * 841),
nHeight: Math.round((72 / 25.4) * 594)
});
[...Array(numPages - 1)].forEach( (_null, i) => {
const pageNum = i + 1;
docNew.newPage({
nPage: pageNum,
nWidth: Math.round((72 / 25.4) * 841),
nHeight: Math.round((72 / 25.4) * 594)
});
});
[...Array(numPages)].forEach( (_null, i) => {
const pageNum = i;
const boxCrop = this.getPageBox({
cBox: "Crop", nPage: pageNum
});
const boxMedia = [
0, boxCrop[1] - boxCrop[3], boxCrop[2] - boxCrop[0], 0
];
docNew.setPageBoxes({
cBox: "Crop", nStart: pageNum, nEnd: pageNum, rBox: boxCrop
});
docNew.setPageBoxes({
cBox: "Media", nStart: pageNum, nEnd: pageNum, rBox: boxMedia
});
["Bleed", "Trim", "Art"].forEach( box => {
docNew.setPageBoxes({
cBox: box, nStart: pageNum, nEnd: pageNum
});
});
docNew.addWatermarkFromFile({
cDIPath: this.path,
nSourcePage: pageNum,
nStart: pageNum, nEnd: pageNum,
bOnTop: true, bOnScreen: true, bOnPrint: true,
nHorizAlign: app.constants.align.center,
nVertAlign: app.constants.align.center,
nHorizValue: (72 / 25.4) * 0,
nVertValue: (72 / 25.4) * 0,
bPercentage: false,
nScale: -1,
bFixedPrint: false,
nRotation: 0, nOpacity: 1.0
});
});
})();