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

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<LastPagesNum; i++)
    {
    	app.pdfPlacePreferences.pageNumber = i+1;
        curPage=app.activeDocument.pages[i];  
        curPage.place(File(myFile),Locat); 
         }
}
else{
//Remove the dialog box from memory.
myDialog.destroy();
}

2.作者答疑


  如有疑问,请留言。

提示: 作者知了-联系方式1
提示: 作者知了-联系方式2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值