1 Reply Latest reply on Sep 30, 2011 6:15 AM by Arthur Jedynak

    Issue with Priniting Drawings to PDF

    Arthur Jedynak

      Hi,

      First of all I should mention that for PDM I am using DBWorks.

      I have wrote piece of software which is allowing me to kind of Pack and Go without opening any files in SolidWorks (every thing is done base on the DBWorks Database). To be able for easy exportation of file. (Look at DBWorks Pack).

       

       

      For addition to thta I am attempting to make batch PDF printing from the same software (maybe other things later on). Basicly from the list that is abowe I am attempting to print all drawings. (Look at DBWorks Print)

       

       

      And there is the problem starting. I am using Bullzip PDF Printer. Look at the code below (Visual Basic 2010 Express).

       

                       PartNumber = DataGridView1.SelectedRows.Item(i).Cells.Item(1).FormattedValue.ToString()

                      Folder = DataGridView1.SelectedRows.Item(i).Cells.Item(6).FormattedValue.ToString()

                      revision = DataGridView1.SelectedRows.Item(i).Cells.Item(3).FormattedValue.ToString()

                      sheetFormat = DataGridView1.SelectedRows.Item(i).Cells.Item(5).FormattedValue.ToString()

                      FileName = Folder & PartNumber

       

                      'Get Part Number without extension

                      For count = 1 To Len(PartNumber)

       

                          If Strings.GetChar(PartNumber, count) = "." Then

                              number = Strings.Left(PartNumber, count - 1)

                              Exit For

                          End If

                      Next

       

       

                      Dim output = TextBoxPrintFolder.Text & "\" & number & " " & "-" & " " & "Rev." & revision & ".pdf" 'file name

                      'Initiate printer and set settings

                      PrinterSettings.Init()

                      PrinterSettings.SetValue("Output", output)

                      PrinterSettings.SetValue("ShowSettings", "never")

                      PrinterSettings.SetValue("ShowPDF", "no")

                      PrinterSettings.SetValue("ShowProgress", "no")

                      PrinterSettings.SetValue("ShowProgressFinished", "yes")

                      PrinterSettings.SetValue("SuppressErrors", "yes")

                      PrinterSettings.SetValue("ConfirmOverwrite", "yes")

                      PrinterSettings.SetValue("RememberLastFileName", "no")

                      PrinterSettings.SetValue("RememberLastFolderName", "no")

       

                      PrinterSettings.PrinterName = printer

                      PrinterSettings.WriteSettings(True)

       

                      'Print

                      Bullzip.PdfWriter.PdfUtil.PrintFile(FileName, printer)

                      'Wait for file before sending another one to be printer

                      While FileIO.FileSystem.FileExists(runonce)

                          Bullzip.PdfWriter.PdfUtil.WaitForFile(FileName, 100)

                      End While

       

      This is the setup. When I run it with solid works opened it throws an error, also it alwes reads pagesetup from solidWorks file.

      Without Solid Works open there is no error and every thing works fine (apart form turning on SLD sesion and turning of for each print which is taking a bit of time).

      (Look at Error).

       

       

      I would like to open for printing in SolidWorks (View mode only) or e-Drawings.

      Can anyone help?

      Best Regards,

      Arthur

        • Re: Issue with Priniting Drawings to PDF
          Arthur Jedynak

          Hi All,

          I found solution by myself. I had to use SolidWorks to open document and set page setup and then print through BullZip printer. Here is some code:

           

          'Get Part Number without extension

                          For count = 1 To Len(PartNumber)

           

                              If Strings.GetChar(PartNumber, count) = "." Then

                                  number = Strings.Left(PartNumber, count - 1)

          Exit For

                              End If

                          Next

           

           

           

                          swApp = GetObject(, "SldWorks.Application")

           

                          swModel = swApp.OpenDoc2(FileName, 3, True, True, False, 0)

                          pageSetup = swModel.PageSetup

           

                          If sheetFormat <> "A4 vert." Then

           

                              pageSetup.Orientation = 2

                          Else

                              pageSetup.Orientation = 1   ' 1=Portrait  '2 = Landscape

                          End If

           

                          'Paper size 7 = A4Vertical, 8 = A3, 9 = A2, 10 = A1, 11 = A0

           

                          If sheetFormat = "A4 vert." Then

                              pageSetup.PrinterPaperSize = 7

                          ElseIf sheetFormat = "A3" Then

                              pageSetup.PrinterPaperSize = 8

                          ElseIf sheetFormat = "A2" Then

                              pageSetup.PrinterPaperSize = 9

                          ElseIf sheetFormat = "A1" Then

                              pageSetup.PrinterPaperSize = 10

                          ElseIf sheetFormat = "A0" Then

          pageSetup.PrinterPaperSize = 11

                          End If

           

                          pageSetup.ScaleToFit = True

                          swModelDocExt = swModel.Extension

           

                          Dim output As String = TextBoxPrintFolder.Text & "\" & number & " " & "-" & " " & "Rev." & revision & ".pdf" 'file name

                          'Initiate printer and set settings

                          PrinterSettings.Init()

                          PrinterSettings.SetValue("Output", output)

                          PrinterSettings.SetValue("ShowSettings", "never")

                          PrinterSettings.SetValue("ShowPDF", "no")

                          PrinterSettings.SetValue("ShowProgress", "no")

                          PrinterSettings.SetValue("ShowProgressFinished", "yes")

                          PrinterSettings.SetValue("SuppressErrors", "yes")

                          PrinterSettings.SetValue("ConfirmOverwrite", "yes")

                          PrinterSettings.SetValue("RememberLastFileName", "no")

                          PrinterSettings.SetValue("RememberLastFolderName", "no")

           

                          PrinterSettings.PrinterName = printer

                          PrinterSettings.WriteSettings(True)

                          'Print

                          swModelDocExt.PrintOut3(0, 1, False, printer, "", True)

                                         swApp.CloseDoc(FileName)

           

           

          Also I have added extension to this small apllication. Export of flat pattern to dxf. I works very good.

          DXF export.jpg