Printing and margins

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
merco
Posts: 28
Joined: 25 May 2010, 10:03

Printing and margins

Post by merco » 30 May 2010, 14:19

i'm using a kind of silent print with this code to Bullzip pdf printer , but in every file (and also in the standard preview) i see always a lot of margin space that is wasted.
It seems that "CADImport.Printing.DrawingSize.Fit" doesn't really FIT to printer page.
To test it i've plot 2 points at:
P.Point = New DPoint(_cadImage.PureExtents.left, _cadImage.PureExtents.bottom, 0)
P.Point = New DPoint(_cadImage.PureExtents.right, _cadImage.PureExtents.top, 0)

Another question is:
How can i calculate the visible object extension after hiding layes/block ? _cadImage.PureExtents return always the same points

Code: Select all

 _cadImage.GetExtents()
Dim prtForm As CADImport.Printing.PrintingForm
prtForm = New CADImport.Printing.PrintingForm
prtForm.Image = _cadImage

prtForm.CreateNewPages()
_Orientation = Orientation
_Format = PaperSize
prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
ImpostaPrt2(prtForm.PrintDocument)


 Private Sub ImpostaPrt2(ByRef Pd As System.Drawing.Printing.PrintDocument)
        Dim ps As System.Drawing.Printing.PaperSize = Nothing
        Pd.PrinterSettings.PrinterName = _PrinterName
        For Each ps In Pd.PrinterSettings.PaperSizes
            Select Case _Format
                Case PaperFormat.A3
                    If ps.PaperName = "A3" Then
                        Exit For
                    End If
                Case PaperFormat.A4
                    If ps.PaperName = "A4" Then
                        Exit For
                    End If
                Case PaperFormat.A2
                    If ps.PaperName = "A2" Then
                        Exit For
                    End If
                Case PaperFormat.A1
                    If ps.PaperName = "A1" Then
                        Exit For
                    End If
                Case PaperFormat.A0
                    If ps.PaperName = "A0" Then
                        Exit For
                    End If

                Case Else
            End Select
        Next

        Pd.DefaultPageSettings.PrinterSettings.PrinterName = _PrinterName
        Pd.DefaultPageSettings.PaperSize = ps
        Pd.DefaultPageSettings.Margins.Left = 5
        Pd.DefaultPageSettings.Margins.Right = 5
        Pd.DefaultPageSettings.Margins.Bottom = 5
        Pd.DefaultPageSettings.Margins.Top = 5

        If _Orientation = PaperOrientation.Oriz Then
            Pd.DefaultPageSettings.Landscape = True
        Else
            Pd.DefaultPageSettings.Landscape = False
        End If
        Pd.Print()
    End Sub
Attachments
PROVA.PDF.zip
Test pdf (B/W) (rename to pdf)
(10.81 KiB) Downloaded 1292 times

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Printing and margins

Post by support » 31 May 2010, 15:18

Hello.
Unfortunateiy it seems the PROVA.PDF.zip file that you upload to this topic is corrupted and I couldn't see the picture. However the issue can depend on margins of CADImage object. Please try to add the following strings to your code:

Code: Select all

_cadImage.IsWithoutMargins = True
_cadImage.BorderSize = 0
when create _cadImage object (before loading file) and see the results of your printing method.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Printing and margins

Post by merco » 31 May 2010, 16:11

that works !

merco
Posts: 28
Joined: 25 May 2010, 10:03

Re: Printing and margins

Post by merco » 01 Jun 2010, 12:48

... "fit" is useful for use all page , but how can i maintain the correct aspect ratio ?

It seems that print preview is different from EXE and sources.

The right version of the preview seems to be the second one (white background), why with this

Code: Select all

        _cadImage.ClearSelection()
        _cadImage.ClearMarkers()
        _cadImage.GetExtents()
        Dim prtForm As CADImport.Printing.PrintingForm
        prtForm = New CADImport.Printing.PrintingForm
        prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
        prtForm.Image = _cadImage
        prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
        prtForm.CreateNewPages()

        _Orientation = Orientation
        _Format = PaperSize
        prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
i get a streched image ?
Attachments
Example
Example
diff_print_prev.jpg (244.75 KiB) Viewed 23095 times

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Printing and margins

Post by support » 03 Jun 2010, 15:12

Hello.
You don't need specify the page orientation - its calculated automatically. This is the cause of distortion. A4 format used by default. Just specify the page size, if different from A4 and you will get the correct result:

Code: Select all

            prtForm = New CADImport.Printing.PrintingForm

            Dim size As System.Drawing.Printing.PaperSize
            size = New System.Drawing.Printing.PaperSize

REM: please note, setting PaperKind.A5Rotated will result in distorted print because the page orientation calculated automatically

            size.RawKind = System.Drawing.Printing.PaperKind.A5

            prtForm.PrintDocument.DefaultPageSettings.PaperSize = size
            prtForm.PrintDocument.PrinterSettings.PrinterName = printer_name

            prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
            prtForm.Image = loaded_CADImage
            prtForm.Print(True)
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply