如何使用visual studio 2010在adobe indesign cs5中放置多个pdf [英] How to place a multiple pdf in adobe indesign cs5 using visual studio 2010

查看:121
本文介绍了如何使用visual studio 2010在adobe indesign cs5中放置多个pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用visual studio 2010在adobe indesign cs5中放置多个pdf。







作为参考,我有一个vbs代码....但我需要一个使用visual studio 2010的示例项目。



请帮我转换这个vbs代码到visual basic 2010项目....





我的邮件ID是DELETED@gmail.com





adobe indesign的Vbs代码cs5:





How to place a multiple pdf in adobe indesign cs5 using visual studio 2010.



For the reference i have a vbs code for this .... but i need a sample project using visual studio 2010.

Please help me to convert this vbs code to visual basic 2010 project....


My mail id is DELETED@gmail.com


Vbs code for adobe indesign cs5 :


Rem PlaceMultipagePDF.vbs
Rem An InDesign CS5 script
Rem
Rem Places all of the pages of a multi-page PDF.
Rem
main
Function main()
	Set myInDesign = CreateObject("InDesign.Application")
	Rem Set the user interaction level to allow the display of dialog boxes and alerts.
	myInDesign.ScriptPreferences.UserInteractionLevel = idUserInteractionLevels.idInteractWithAll
	Rem Use JavaScript to display a standard Open File dialog box.
	myJavaScript = "myPDFFile = File.openDialog(""Choose a PDF File"");if(myPDFFile != null){myFileName = myPDFFile.fsName}else{myFileName = """"};"
	myFileName = myInDesign.DoScript(myJavaScript, idScriptLanguage.idJavascript)
	If myFileName <> "" Then
	    myNewDocument = True
	    If myInDesign.Documents.Count <> 0 Then
	        Set myDocument = myChooseDocument(myInDesign, myNewDocument)
	    Else
	        Set myDocument = myInDesign.Documents.Add
	    End If
	    If myNewDocument = False Then
	        Set myPage = myChoosePage(myInDesign, myDocument)
	    Else
	        Set myPage = myDocument.Pages.Item(1)
	    End If
	    myPlacePDF myInDesign, myDocument, myPage, myFileName
	End If
End function
Function myChooseDocument(myInDesign, myNewDocument)
    ReDim myDocumentNames(0)
    myDocumentNames(0) = "New Document"
    Rem Get the names of the documents
    For myDocumentCounter = 1 To myInDesign.Documents.Count
        ReDim Preserve myDocumentNames(UBound(myDocumentNames) + 1)
        myDocumentNames(myDocumentCounter) = myInDesign.Documents.Item(myDocumentCounter).Name
    Next
    Set myChooseDocumentDialog = myInDesign.Dialogs.Add
    myChooseDocumentDialog.Name = "Choose a Document"
    myChooseDocumentDialog.CanCancel = False
    With myChooseDocumentDialog.DialogColumns.Add
        With .DialogRows.Add
            With .DialogColumns.Add
                With .StaticTexts.Add
                    .StaticLabel = "Place PDF in:"
                End With
            End With
            With .DialogColumns.Add
                Set myChooseDocumentDropdown = .Dropdowns.Add
                myChooseDocumentDropdown.StringList = myDocumentNames
                myChooseDocumentDropdown.SelectedIndex = 0
            End With
        End With
    End With
    myChooseDocumentDialog.Show
    If myChooseDocumentDropdown.SelectedIndex = 0 Then
        Set myDocument = myInDesign.Documents.Add
    Else
        Set myDocument = myInDesign.Documents.Item(myChooseDocumentDropdown.SelectedIndex)
        myNewDocument = False
    End If
    myChooseDocumentDialog.Destroy
    Set myChooseDocument = myDocument
End Function
Function myChoosePage(myInDesign, myDocument)
    ReDim myPageNames(0)
    Rem Get the names of the pages in the document
    For myCounter = 1 To myDocument.Pages.Count
        If Not (IsEmpty(myPageNames(0))) Then
            ReDim Preserve myPageNames(UBound(myPageNames) + 1)
        End If
        myPageNames(myCounter - 1) = myDocument.Pages.Item(myCounter).Name
    Next
    Set myChoosePageDialog = myInDesign.Dialogs.Add
    myChoosePageDialog.Name = "Choose a Page"
    myChoosePageDialog.CanCancel = False
    With myChoosePageDialog.DialogColumns.Add
        With .DialogRows.Add
            With .DialogColumns.Add
                With .StaticTexts.Add
                    .StaticLabel = "Place PDF on:"
                End With
            End With
            With .DialogColumns.Add
                Set myChoosePageDropdown = .Dropdowns.Add
                myChoosePageDropdown.StringList = myPageNames
                myChoosePageDropdown.SelectedIndex = 0
            End With
        End With
    End With
    myChoosePageDialog.Show
    Set myPage = myDocument.Pages.Item(myChoosePageDropdown.SelectedIndex + 1)
    myChoosePageDialog.Destroy
    Set myChoosePage = myPage
End Function
Function myPlacePDF(myInDesign, myDocument, myPage, myFileName)
    myInDesign.PDFPlacePreferences.PDFCrop = idPDFCrop.idCropMedia
    myCounter = 1
    myBreak = False
    Do While myBreak = False
        If myCounter > 1 Then
            myDocument.Pages.Add
        End If
        myInDesign.PDFPlacePreferences.PageNumber = myCounter
        Set myPDFPage = myDocument.Pages.Item(-1).Place(myFileName, Array(0, 0))
      	Set myPDFPage = myPDFPage.Item(1)
        If myCounter = 1 Then
            myFirstPage = myPDFPage.PDFAttributes.PageNumber
        Else
            If myPDFPage.PDFAttributes.PageNumber = myFirstPage Then
                myDocument.Pages.Item(-1).Delete
                myBreak = True
            End If
        End If
        myCounter = myCounter + 1
    Loop
End Function





SHOUTING已删除,电子邮件删除,添加了代码块 - OriginalGriff [/ edit]



[edit]SHOUTING removed, Email removed, Code block added - OriginalGriff[/edit]

推荐答案

这篇关于如何使用visual studio 2010在adobe indesign cs5中放置多个pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆