I have written a Drawing Issuing Program in VB.net. 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")
'Set Print Manager to print to File
m_printMgr.PrintToFile = True
'Set Print Manager to print to File Name
m_printMgr.PrintToFileName = PDFtoFile
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)
After I get this working, I need to set the Adobe Save As window to the correct location.
Have you tried the sample at <<Revit SDK>>\Samples\ViewPrinter\CS ?
It is similar to want you described.
Autodesk Developer Network