您当前的位置: 首页 > 

插件开发

暂无认证

  • 3浏览

    0关注

    492博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

InDesign插件--常规功能开发--多页PDF导入--js脚本开发--ID插件

插件开发 发布时间:2022-03-10 07:58:27 ,浏览量:3

文章目录
    • 1.算法程序
    • 2.作者答疑

1.算法程序

  Adobe InDesign是Adobe公司的一个桌面出版 (DTP) 的应用程序,主要用于各种印刷品的排版编辑。InDesign可以将文档直接导出为Adobe的PDF格式,而且有多语言支持。采用脚本语言自动化编码,在学习中的一个重要功能是多页PDF导入功能,以下源代码仅用于学习交流,请勿用于商业用途和其它非法用途。源代码如下所示:

//PlacePDFPages.js 
//Select the file you want to place.
var myFile = File.openDialog("Select the file you want to place", "");
//Create a dialog.
var myDialog = app.dialogs.add({name:"PDF多页面导入",canCancel:true});
with(myDialog){
  //Add a dialog column.
  with(dialogColumns.add()){
    //Create First border panel.
    with(borderPanels.add()){
      with(dialogColumns.add()){
        staticTexts.add({staticLabel:"导入PDF从第1页到第n页:"});
      }
      with(dialogColumns.add()){
        //Create a number entry field.Note that this uses editvalue
        //rather than editerText (as a textBox would).
       var LastPagesNumField = realEditboxes.add({editValue:5});
      }
    }
    //Create Second border panel.
    with(borderPanels.add()){
    	with(dialogColumns.add()){
    	  staticTexts.add({staticLabel:"PDF页面左上角定位于X坐标(mm):"});
         }
      with(dialogColumns.add()){
        //Create a number entry field.Note that this uses editvalue
        //rather than editerText (as a textBox would).
       var TopLeftXField = realEditboxes.add({editValue:0});
      }
    }
    //Create Third border panel.
    with(borderPanels.add()){
    	with(dialogColumns.add()){
    	  staticTexts.add({staticLabel:"PDF页面左上角定位于Y坐标(mm):"});
         }
      with(dialogColumns.add()){
        //Create a number entry field.Note that this uses editvalue
        //rather than editerText (as a textBox would).
       var TopLeftYField = realEditboxes.add({editValue:0});
      }
    }      
  }
}
//Display the dialog box.
if(myDialog.show() == true){ 
//Get the LastPagesNum from the LastPagesNumField.
LastPagesNum = LastPagesNumField.editValue;
TopLeftX=TopLeftXField.editValue;
TopLeftY=TopLeftYField.editValue;

var myDocument = app.activeDocument;  	
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.millimeters;  	
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.millimeters;  

Locat = [TopLeftX, TopLeftY];

app.pdfPlacePreferences.pdfCrop=PDFCrop.cropMedia;  
myDocument.documentPreferences.pagesPerDocument = LastPagesNum; 
for (i=0; i            
关注
打赏
1665481431
查看更多评论
0.0383s