Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :


VB
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


[edit]SHOUTING removed, Email removed, Code block added - OriginalGriff[/edit]
Posted
Updated 18-Apr-14 1:03am
v3
Comments
OriginalGriff 18-Apr-14 7:03am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know.
MRIGANKA BHUSAN DEBNATH 18-Apr-14 7:41am    
Sory

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900