Advertisement
ViktorEngard

InDesign script to show PDF options

Sep 16th, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ShowPDFoptions.jsx
  2.  
  3. // Version 2
  4.  
  5. // An InDesign CS and CS2 Javascript
  6.  
  7. // Allows you to change the properties of an imported PDF
  8. // such as crop, imported page, transparent background
  9. // whilst keeping all the properties of the object.
  10.  
  11. // Install into your indesign/scripts directory
  12.  
  13. // Select a box containing an imported PDF and run this script
  14. // by selecting it in the scripts palette.
  15.  
  16. // www.luxlucid.com
  17.  
  18. // Modified for CS3 and above by viktor@engard.hu
  19.  
  20. myDoc = app.activeDocument;
  21.  
  22. if( myDoc.selection.length == 0 ){err("No selection.");}
  23.  
  24. if( myDoc.selection[0].constructor.name != "PDF" ){
  25. //Test if it is a container
  26. try {
  27.     if (myDoc.selection[0].contentType == ContentType.graphicType){
  28.         //Is first content PDF?
  29.             try {
  30.                     if (myDoc.selection[0].allGraphics[0].constructor.name == "PDF"){
  31.                         placePDF(myDoc.selection[0].allGraphics[0]);
  32.                     } else {
  33.                         err("No PDF content embedded.");
  34.                     }
  35.             } catch (e){
  36.                 err("No PDF content embedded.");
  37.             }
  38.     } else {
  39.         err("Select an imported PDF.");
  40.     }
  41. } catch (e){
  42.     err("Select an imported PDF.");
  43. }
  44.  
  45.  
  46. } else {
  47.     placePDF(myDoc.selection[0]);
  48. }
  49.  
  50. exit();
  51.  
  52.  
  53. function placePDF(n){
  54.     try {
  55.     if (app.version == 3){
  56.         //cs1
  57.         myDoc.selection[0].place(n.itemLink.filePath,1,1,1,1, undefined);
  58.     } else if (String(app.version).split(".")[0] == 4){
  59.         //cs2
  60.         myDoc.selection[0].place(n.itemLink.filePath,1, undefined);
  61.     } else if (String(app.version).split(".")[0] > 4){
  62.         //cs3+
  63.         myDoc.selection[0].place(n.itemLink.filePath,1, undefined);
  64.     }
  65.    
  66.     } catch (e){
  67.         err("Unknown error!");
  68.     }
  69. }
  70.  
  71.  
  72.  
  73. function err(e){
  74.     alert(e);
  75.     exit();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement