// Rotatepages.js // script to rotate pages for top binding (e.g. calendars) // Made by Teus de Jong -- version of November 18, 2005 // Works now in CS3 -- February 25, 2008 if (app.documents.length == 0){ alert('No documents are open.'); exit(); } v = app.version; v1 = app.scriptPreferences.version; if (app.version == 3) pdfpreset = '[Press]'; else { pdfpreset = '[Press Quality]'; IsCS3 = v.substring(0, 3) == '5.0'; } pdfname = app.activeDocument.name.replace('.indd', '.pdf'); topbottom = 0; if (!doDisplayDialog()){ exit(); } pdfname = app.activeDocument.filePath + '/' + pdfname; app.activeDocument.exportFile(ExportFormat.pdfType, File(pdfname), false, pdfpreset); with (app.activeDocument.documentPreferences){ newheight = pageWidth; newwidth = pageHeight; nrofpages = pagesPerDocument; } with (newdoc = app.documents.add()){ documentPreferences.pageHeight = newheight; documentPreferences.pageWidth = newwidth; documentPreferences.pagesPerDocument=nrofpages; } with (app.pdfPlacePreferences){ pdfCrop = PDFCrop.cropPDF; transparentBackground = true; } for (i = 0; i < nrofpages; i++){ app.pdfPlacePreferences.pageNumber = i+1; if (topbottom == 'Top'){ pdfpage = newdoc.pages[i].place(File(pdfname), [0, newheight]); if (IsCS3) { pdfpage = pdfpage[0]; pdfpage.parent.transform (CoordinateSpaces.parentCoordinates, AnchorPoint.topLeftAnchor, [0, -1, 1, 0, 0, 0]); } else pdfpage.parent.rotate(90, AnchorPoint.topLeftAnchor); } else { pdfpage = newdoc.pages[i].place(File(pdfname), [newwidth, 0]); if (IsCS3) { pdfpage = pdfpage[0]; pdfpage.parent.transform (CoordinateSpaces.parentCoordinates, AnchorPoint.topLeftAnchor, [0, 1, -1, 0, 0, 0]); } else pdfpage.parent.rotate(-90, AnchorPoint.topLeftAnchor); } } function doDisplayDialog(){ with (theDialog = app.dialogs.add({name:'Choose PDF Preset and PDF Filename'})){ //Add a dialog column. DialogColumn1 = dialogColumns.add(); with (DialogColumn1){ staticTexts.add({staticLabel:'PDF Filename:'}); staticTexts.add({staticLabel:'PDF Preset:'}); staticTexts.add({staticLabel:'Top/bottom binding:'}); } DialogColumn2 = dialogColumns.add(); with (DialogColumn2){ with (editpdfname = textEditboxes.add()){ editContents = pdfname; minWidth = 150; } with (presetbox = dropdowns.add()){ stringList = app.pdfExportPresets.everyItem().name; for (i = 0; i < stringList.length; i++){ if (stringList[i] == pdfpreset){ selectedIndex = i; break; } } } with (topbottombox = dropdowns.add()){ stringList = ['Top', 'Bottom']; selectedIndex = 0; } } if (theDialog.show()) { pdfname = editpdfname.editContents; pdfpreset = presetbox.stringList[presetbox.selectedIndex]; topbottom = topbottombox.stringList[topbottombox.selectedIndex]; theDialog.destroy; return(true); } else{ theDialog.destroy(); return(false); } } }