Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1.  
  2.  
  3. //Display a standard Open File dialog box.
  4. var myPDFFile = File.openDialog("Choose a PDF File");
  5. if((myPDFFile != "")&&(myPDFFile != null)){
  6. var myDocument, myPage;
  7. myDocument = app.documents.add();
  8.  
  9. var myN = "";
  10. for (var i=(myPDFFile.parent.toString().length+2); i<myPDFFile.fsName.toString().length; i++) {
  11.  
  12. myN = myN + myPDFFile.fsName.toString()[i];
  13.  
  14. }
  15.  
  16.  
  17. // salva preferenza misure
  18. var myOldXUnits = app.activeDocument.viewPreferences.horizontalMeasurementUnits;
  19. var myOldYUnits = app.activeDocument.viewPreferences.verticalMeasurementUnits;
  20. //Set the measurement units to mm
  21. app.activeDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;
  22. app.activeDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;
  23.  
  24. with(myDocument.documentPreferences){
  25. pageHeight = 700;
  26. pageWidth = 500;
  27. }
  28.  
  29. myPage = myDocument.pages.item(0);
  30. myPDFPage = myPage.place(File(myPDFFile), [0,0])[0];
  31.  
  32.  
  33. //selezioni contenitore
  34. mBox = myPDFPage.parent;
  35.  
  36. //dimensione 500x700mm
  37. mBox.geometricBounds = [0,0, 700, 500];
  38.  
  39. //adatta dimensione contenuto
  40. mBox.fit(FitOptions.contentToFrame);
  41.  
  42. //centra contenuto
  43. mBox.fit(FitOptions.centerContent);
  44.  
  45. //seleziona cartella
  46. myFolder= Folder.selectDialog ("Choose a Folder");
  47.  
  48. if(myFolder != null){
  49.  
  50. if(File.fs == "Macintosh"){
  51.  
  52. myFilePath = myFolder.fsName + "/" + myN;
  53. app.activeDocument.exportFile(ExportFormat.pdfType, myFilePath, false);
  54.  
  55. }
  56. else{
  57.  
  58. myFilePath = myFolder.fsName + "/" + myPDFFile.displayName;
  59. app.activeDocument.exportFile(ExportFormat.pdfType, myFilePath, false);
  60.  
  61. }
  62.  
  63. }
  64.  
  65.  
  66. //Reset measurement units to their original values.
  67. app.activeDocument.viewPreferences.horizontalMeasurementUnits = myOldXUnits;
  68. app.activeDocument.viewPreferences.verticalMeasurementUnits = myOldYUnits;
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement