API Export to PDF not printing the LayoutX sheets
I am trying to run a simple program that opens a DWG and exports all sheets except 'Model' to PDF. This works fine when done manually but using the API, I get a blank sheet. Using the following code (VB.NET) :
Private Sub ExpFile(ByVal Dapp Application, ByVal filename As String) Try Dim dsDoc As Document Dim dsPrintMgr As PrintManager Dim Length As Double Dim width As Double
dsDoc = Dapp.OpenDocument2(filename, dsDocumentOpenOption_e.dsDocumentOpen_ReadOnly, dsEncoding_e.dsEncoding_Default) If dsDoc Is Nothing Then MsgBox("Specified document did not open. Check path and file name.") Exit Sub End If Dim sheets As Object Dim sheet As Sheet sheets = dsDoc.GetSheets Dim sheetNames() As String Dim counter As Integer = 0
For i As Integer = 0 To UBound(sheets) sheet = sheets(i) If Not sheet.Name.ToLower = "model" Then
ReDim Preserve sheetNames(counter) sheetNames(counter) = sheet.Name counter = counter + 1 End If
Next Dim dsExportDocument As DocumentExporter dsExportDocument = dsDoc.GetDocumentExporter() Dim retval As Boolean Dim pdfName As String pdfName = IO.Path.GetFileNameWithoutExtension(filename) Dim dirName As String dirName = IO.Path.GetDirectoryName(filename) pdfName = dirName & "\\" & pdfName & ".pdf"
dsExportDocument.ExportToPdf(pdfName, sheetNames, 1189, 841, retval) Dapp.CloseDocument(filename, False) sheets = Nothing dsDoc = Nothing Catch ex As Exception getError(filename & " " & ex.Message)
End Try
