Cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble Printing Batch PDFs

Creator
Creator

We have been using a custom batch program to print .dft to pdfs.  It works by going from the draft to PS to PDF via ghostscript.  It worked well in Windows 7 and ST9 and versions lower, however its not working for me in Windows 10 or SE 2019 (in windows 7).  My biggest issue comes with printing A1 and B1 sized drawings.  It does work for A3 sizes.

 

The Issue:

All A1 drafts (in solid edge) PDF to ANSI D (34" x 22")

All B1 drafts (in solid edge) PDF to 60" x 24"

 

 

Possible Cause:

in VB.net are using the following sheet sizes, as they are not part of the PaperKind list:

A0 = 121

A1 = 122

B1 = 142

 

I have a feeling that those numbers are not right.  Would anybody have any guidance for me:

 

Here is the code:

 

Select Case objSheet.SheetSetup.SheetSizeOption


Case SolidEdgeDraft.PaperSizeConstants.igIsoA0Tall
          lPaperSize = 121
          lPaperOrient = vbPRORPortrait
Case SolidEdgeDraft.PaperSizeConstants.igIsoA0Wide
          lPaperSize = 121
          lPaperOrient = vbPRORLandscape
Case SolidEdgeDraft.PaperSizeConstants.igIsoA1Tall
          lPaperSize = 122
          lPaperOrient = vbPRORPortrait
Case SolidEdgeDraft.PaperSizeConstants.igIsoA1Wide
          lPaperSize = 122
          lPaperOrient = vbPRORLandscape
Case SolidEdgeDraft.PaperSizeConstants.igIsoA2Tall
          lPaperSize = PaperKind.A2
          lPaperOrient = vbPRORPortrait
Case SolidEdgeDraft.PaperSizeConstants.igIsoA2Wide
          lPaperSize = PaperKind.A2
          lPaperOrient = vbPRORLandscape
Case SolidEdgeDraft.PaperSizeConstants.igIsoA3Tall
          lPaperSize = PaperKind.A3
          lPaperOrient = vbPRORPortrait
Case SolidEdgeDraft.PaperSizeConstants.igIsoA3Wide
          lPaperSize = PaperKind.A3
          lPaperOrient = vbPRORLandscape
Case SolidEdgeDraft.PaperSizeConstants.igIsoA4Tall
          lPaperSize = PaperKind.A4
          lPaperOrient = vbPRORPortrait
Case SolidEdgeDraft.PaperSizeConstants.igIsoA4Wide
          lPaperSize = PaperKind.A4
          lPaperOrient = vbPRORLandscape
Case SolidEdgeDraft.PaperSizeConstants.igCustomSheetSize
          If objSheet.SheetSetup.SheetWidth = 1.0 And
          objSheet.SheetSetup.SheetHeight = 0.707 Then
          'Then B1 size landscape
          lPaperSize = 142
          lPaperOrient = vbPRORLandscape
ElseIf objSheet.SheetSetup.SheetWidth = 0.707 And
objSheet.SheetSetup.SheetHeight = 1.0 Then
          'Then B1 size portrait
          lPaperSize = 142
          lPaperOrient = vbPRORPortrait
End If

 

Thanks,

4 REPLIES

Re: Trouble Printing Batch PDFs

Legend
Legend

azia,

  •  open exel sheet
  • start macro
  • change Sheet size
  • print (to pdf)
  • finish macro

You should get something like this:

..........

    With ActiveSheet.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.7)
        .RightMargin = Application.InchesToPoints(0.7)
        .TopMargin = Application.InchesToPoints(0.787401575)
        .BottomMargin = Application.InchesToPoints(0.787401575)
        .HeaderMargin = Application.InchesToPoints(0.3)
        .FooterMargin = Application.InchesToPoints(0.3)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .CenterHorizontally = False
        .CenterVertically = False
        .Orientation = xlPortrait
        .Draft = False
        .PaperSize = 154
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = 100
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With

............

 

regards

Gerald

Betreff: Trouble Printing Batch PDFs

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Hi @azia

 

 

and what's about using the SaveAs PDF method?

 

This IMHO will make what is requested.

Just using the given paper size.

regards
Wolfgang

Betreff: Trouble Printing Batch PDFs

Creator
Creator

I was trying not to re-write the code.  Going to .ps allows us to use the program to batch multiple drawings into a single PDF.  It also allows us to send the .ps to a printer instead of making a PDF, which are items I am trying to preserve.  I have been trying to manually set the ghostscript papersize w/ the argument '-sPaperSize=b1' (for example) and still having no luck.  I cant tell if gs is pickup up the papersize properly from the .ps.

Betreff: Trouble Printing Batch PDFs

Creator
Creator

I did not find any references for the paperkind size attributes above 119, so I had no choice but to check each one individually.  The good news is that I was able to find the new codes for A0, A1 & B1!

 

A0 went from 121 to 128

A1 went from 122 to 127

B1 went from 142 to 167

 

I am not sure why, but all is well again.  Onto the next problem!