Public Sub Set_Printer_Parameters()
' Проверка наличия принтера PDF
Dim App As Autodesk.Revit.UI.UIApplication = Me.ExComData.Application
Dim UIDoc As UIDocument = App.ActiveUIDocument
Dim Doc As Document = App.ActiveUIDocument.Document
Dim tr As New Transaction(Doc, "Set PDF printer parameters")
tr.Start()
Dim myPM As PrintManager = Doc.PrintManager
myPM.PrintRange = PrintRange.Current
myPM.Apply()
myPM.SelectNewPrintDriver("PDFCreator")
myPM.Apply()
If myPM.IsVirtual = VirtualPrinterType.AdobePDF Then
'myPM.CombinedFile = False
myPM.PrintToFile = True
myPM.Apply()
Else
tr.Commit()
tr.Dispose()
Exit Sub
End If
Dim curPDFFN As String = Format(Now(), "HHmmssddMMyyyy")
myPM.PrintToFileName = "C:\Users\Pashin.Evgeniy\Desktop\pdf_" & curPDFFN & ".pdf"
myPM.Apply()
Dim myPS As PrintSetup = myPM.PrintSetup
Dim myIPS As IPrintSetting = myPS.CurrentPrintSetting
myIPS.PrintParameters.ColorDepth = ColorDepthType.GrayScale
myIPS.PrintParameters.HiddenLineViews = HiddenLineViewsType.VectorProcessing
myIPS.PrintParameters.HideCropBoundaries = True
myIPS.PrintParameters.HideReforWorkPlanes = True
myIPS.PrintParameters.HideScopeBoxes = True
myIPS.PrintParameters.HideUnreferencedViewTags = False
myIPS.PrintParameters.PaperPlacement = PaperPlacementType.Margins
myIPS.PrintParameters.MarginType = MarginType.UserDefined
myIPS.PrintParameters.UserDefinedMarginX = 0
myIPS.PrintParameters.UserDefinedMarginY = 0
myIPS.PrintParameters.RasterQuality = RasterQualityType.High
myIPS.PrintParameters.ZoomType = ZoomType.FitToPage
myIPS.PrintParameters.PageOrientation = PageOrientationType.Portrait
Dim myPSize As PaperSizeSet = myPM.PaperSizes
For Each myPSP As PaperSize In myPSize
If myPSP.Name = "A4x3_Gallurgy" Then
myIPS.PrintParameters.PaperSize = myPSP
End If
Next
myPS.SaveAs("Setting " & curPDFFN)
myPM.Apply()
Dim myPMPS As FilteredElementCollector = New FilteredElementCollector(Doc).OfClass(GetType(Autodesk.Revit.DB.PrintSetting))
For Each PS As PrintSetting In myPMPS
If PS.Name = "Setting " & curPDFFN Then
Doc.PrintManager.PrintSetup.CurrentPrintSetting = PS
End If
Next
tr.Commit()
tr.Dispose()
myPM.SubmitPrint()
myPM.Apply()
End Sub