Hi, try this (add code from line 18 to 20)
var doc = app.activeDocument;
var mItems=doc.allPageItems;
var len = mItems.length;
// save measurement unit & set measurement unit to mm
savedUnits = app.scriptPreferences.measurementUnit;
app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
while(len--){
var mItem = mItems[len];
var mBounds = mItem.geometricBounds;
var mX = getRound(mBounds[1],3);
var mY= getRound(mBounds[0],3);
// fit content
if(mX == 10 && mY == 10){
mItem.fit(FitOptions.FILL_PROPORTIONALLY);
}
if(mX == 6.999 && mY == 4.801){
resizeItem(mItem, 240,340)
mItem.move([10, 10]);
mItem.fit(FitOptions.FILL_PROPORTIONALLY);
}
}
// restore measurement unit
app.scriptPreferences.measurementUnit = savedUnits;
// export PDF
var _PDFExportPreset = app.pdfExportPresets.item('MyJobOptionName');
if (_PDFExportPreset == null){
alert('PDF Export Presets not found');
exit();
}
app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;
doc.exportFile(ExportFormat.pdfType, _PDFfile, false,_PDFExportPreset);
/* round */
function getRound(number, digits) {
digits = (digits) ? Math.pow(10, digits) : 1000;
return Math.round(number * digits) / digits;
}
/* resize object */
function resizeItem(mItem, mWidth,mHeight) {
mBounds = mItem.geometricBounds;
mBounds[3] = mBounds[1] + mWidth;
mBounds[2] =mBounds[0] + mHeight;
mItem.geometricBounds = mBounds;
}
... View more