Revit API

Active Member
Posts: 9
Registered: ‎03-04-2010
Message 1 of 2 (553 Views)

Specify Print Setup Name

553 Views, 1 Replies
01-11-2012 01:56 PM

I have written a Drawing Issuing Program in So far it works with exporting DWGs and DWFs to specific project folders based on the Central Model location. I am now trying to add a PDF printing routine with great difficulty. We have Acrobat Pro installed so we have the Adobe PDF printer installed on machines. I have a Print Setup in our Project Template called “PDF 42x30 FULL-BLK”. I currently have code that will start printing process, but cannot seem to set the PrintManager.PrintSetup. I found a piece of code that seem to look like what I want but continues to fail. Here is the code that I seem to have trouble with.


    Private Sub CreateAndPrintViewSet(ByVal document As Document, ByVal viewSet As ViewSet)

        'Set the print range to the current view

        m_printMgr.PrintRange = Autodesk.Revit.DB.PrintRange.Current

        'Set file name for PDF

        Dim PDFtoFile As String = Path.Combine(m_pdfFloder, m_pdfFileName)

        If Not SetPrintSettings("PDF 42x30 FULL-BLK") Then

            TaskDialog.Show("PrintPDF", "Unable to set Print Settings")


        End If

        'Set Print Manager to print to File

        m_printMgr.PrintToFile = True

        'Set Print Manager to print to File Name

        m_printMgr.PrintToFileName = PDFtoFile

        'Initailizes Print


    End Sub


    Public Shared Function SetPrintSettings(ByVal name As String) As Boolean

        MessageBox.Show("Start Getting Names")

        For Each ps As Element In m_activeDoc.PrintSettings

            If ps.Name = name Then

                If m_printMgr.PrintSetup.CurrentPrintSetting Is DirectCast(ps, IPrintSetting) Then

                    Dim trans = New Transaction(m_activeDoc)

                    trans.Start("PDF 42x30 FULL-BLK")

                    m_printMgr.PrintSetup.CurrentPrintSetting = DirectCast(ps, IPrintSetting)


                    Return True

                End If

                Return True

            End If


        Return False

    End Function


After I get this working, I need to set the Adobe Save As window to the correct location.

ADN Support Specialist
Posts: 390
Registered: ‎04-30-2009
Message 2 of 2 (546 Views)

Re: Specify Print Setup Name

01-12-2012 05:42 AM in reply to: rickross96



Have you tried the sample at <<Revit SDK>>\Samples\ViewPrinter\CS ?


It is similar to want you described.



Augusto Goncalves


Augusto Goncalves
Autodesk Developer Network
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.