Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Display a standard Open File dialog box.
- var myPDFFile = File.openDialog("Choose a PDF File");
- if((myPDFFile != "")&&(myPDFFile != null)){
- var myDocument, myPage;
- myDocument = app.documents.add();
- var myN = "";
- for (var i=(myPDFFile.parent.toString().length+2); i<myPDFFile.fsName.toString().length; i++) {
- myN = myN + myPDFFile.fsName.toString()[i];
- }
- // salva preferenza misure
- var myOldXUnits = app.activeDocument.viewPreferences.horizontalMeasurementUnits;
- var myOldYUnits = app.activeDocument.viewPreferences.verticalMeasurementUnits;
- //Set the measurement units to mm
- app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
- app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;
- with(myDocument.documentPreferences){
- pageHeight = 700;
- pageWidth = 500;
- }
- myPage = myDocument.pages.item(0);
- myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
- //selezioni contenitore
- mBox = myPDFPage.parent;
- //dimensione 500x700mm
- mBox.geometricBounds = [0,0, 700, 500];
- //adatta dimensione contenuto
- mBox.fit(FitOptions.contentToFrame);
- //centra contenuto
- mBox.fit(FitOptions.centerContent);
- //seleziona cartella
- myFolder= Folder.selectDialog ("Choose a Folder");
- if(myFolder != null){
- if(File.fs == "Macintosh"){
- myFilePath = myFolder.fsName + "/" + myN;
- app.activeDocument.exportFile(ExportFormat.pdfType, myFilePath, false);
- }
- else{
- myFilePath = myFolder.fsName + "/" + myPDFFile.displayName;
- app.activeDocument.exportFile(ExportFormat.pdfType, myFilePath, false);
- }
- }
- //Reset measurement units to their original values.
- app.activeDocument.viewPreferences.horizontalMeasurementUnits = myOldXUnits;
- app.activeDocument.viewPreferences.verticalMeasurementUnits = myOldYUnits;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement