Question
Fixed the PlacedMultipagePDF function so it always centers the PDF even with cropmarks.
Swapped the myPlace PDF function for this one:
function myPlacePDF(myDocument, myPage, myPDFFile) {
app.pdfPlacePreferences.pdfCrop = PDFCrop.cropMedia;
var myCounter = 1;
var myBreak = false;
var myPDFPage;
// Temporarily place to get dimensions
var tempPDF = myPage.place(File(myPDFFile))[0];
var pdfBounds = tempPDF.geometricBounds;
var pdfWidth = pdfBounds[3] - pdfBounds[1];
var pdfHeight = pdfBounds[2] - pdfBounds[0];
tempPDF.remove();
var pageWidth = myPage.bounds[3] - myPage.bounds[1];
var pageHeight = myPage.bounds[2] - myPage.bounds[0];
// Center the frame itself on the page
var offsetX = (pageWidth / 2) - (pdfWidth / 2);
var offsetY = (pageHeight / 2) - (pdfHeight / 2);
while (myBreak == false) {
if (myCounter > 1) {
myPage = myDocument.pages.add(LocationOptions.after, myPage);
}
app.pdfPlacePreferences.pageNumber = myCounter;
myPDFPage = myPage.place(File(myPDFFile), [offsetX, offsetY])[0];
if (myCounter == 1) {
var myFirstPage = myPDFPage.pdfAttributes.pageNumber;
} else{
if (myPDFPage.pdfAttributes.pageNumber == myFirstPage) {
myPage.remove();
myBreak = true;
}}
myCounter++;
}
}
Let me know if any issues come up with it. I've been using it, but don't want to send to friends if there are issues with it. Thanks!
