Print and printing parameters

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

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

Print and printing parameters

Post by merco » 27 May 2010, 18:02

How can i programmatically do some printer settings without showing the "PrintingForm" forms ?

I need to set up (regarding PrintingForm) :
[Device setting section]
Page size : A4
Paper orientation: Landscape
[Drawing setting section]
Format Size
On (A4)
Paper orientation : Landscape

my try:

Code: Select all

        Dim prtForm As CADImport.Printing.PrintingForm
        prtForm = New CADImport.Printing.PrintingForm
        prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
  
        prtForm.Print(True)

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

Re: Print and printing parameters

Post by support » 03 Jun 2010, 15:06

Hello.
Your code is enough to print at A4 format page - it used as default. CAD Import .NET set image landscape or portrait orientation automatically, depends on image extents. Setting prtForm.TypePage=CADImport.Printing.DrawingSize.Fit will stretches the image by the printing page with keeping proportions. The last thing to do is specify the some page format, if you wish to use different from A4 format:

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

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

Re: Print and printing parameters

Post by merco » 03 Jun 2010, 17:54

I'm using "DrawingSize.Fit" (with 7.2.2.19035) but the aspect ratio is not correct.
In the example i've printed to a4 portrait...
This is my code

Code: Select all

Public Sub Open()
        _cadImage = CADImage.CreateImageByExtension(_DwgName)
        _cadImage.UseDoubleBuffering = False
        _cadImage.IsWithoutMargins = True
        _cadImage.BorderSize = 0
        _cadImage.LoadFromFile(_DwgName)


        _cadImage.DrawTextMeansGDIPlusMethods = True
        _cadImage.UseSHXFonts = False
        _cadImage.UseTTFFonts = Not _cadImage.UseSHXFonts
        _cadImage.UseMultyTTFFonts = Not _cadImage.UseSHXFonts
    End Sub


 Private Sub ImpostaPrt2(ByRef Pd As System.Drawing.Printing.PrintDocument)
        Dim ps As System.Drawing.Printing.PaperSize = Nothing
        Pd.PrintController = New System.Drawing.Printing.StandardPrintController


        Pd.PrinterSettings.PrinterName = _PrinterName
        For Each ps In Pd.PrinterSettings.PaperSizes
            Select Case _Format
                Case PaperFormat.A3
                    If ps.RawKind = System.Drawing.Printing.PaperKind.A3 Then

                        Exit For
                    End If
                Case PaperFormat.A4
                    If ps.RawKind = System.Drawing.Printing.PaperKind.A4 Then
                        Exit For
                    End If
                Case PaperFormat.A2
                    If ps.RawKind = System.Drawing.Printing.PaperKind.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

Public Sub SilentPrint2(Optional ByVal PaperSize As PaperFormat = PaperFormat.A4, Optional ByVal Orientation As PaperOrientation = PaperOrientation.Auto, Optional ByVal WaitForFile As Boolean = True, Optional ByVal WaterMark As String = "", Optional ByVal CanPrintPdf As Boolean = True, Optional ByVal CanModifyPdf As Boolean = True)
           

        If Orientation = PaperOrientation.Auto Then
            If Math.Abs(_cadImage.PureExtents.Width) > Math.Abs(_cadImage.PureExtents.Height) Then
                Orientation = PaperOrientation.Oriz
            Else
                Orientation = PaperOrientation.Vert
            End If
        End If
        _cadImage.ClearSelection()
        _cadImage.ClearMarkers()
        _cadImage.GetExtents()
        Dim prtForm As CADImport.Printing.PrintingForm
        prtForm = New CADImport.Printing.PrintingForm

        prtForm.CreateNewPages()

        _Orientation = Orientation
        _Format = PaperSize
        prtForm.Image = _cadImage
        prtForm.TypePage = CADImport.Printing.DrawingSize.Fit
        ImpostaPrt2(prtForm.PrintDocument)
        If WaitForFile Then
            Do
                System.Threading.Thread.Sleep(500)
            Loop Until IO.File.Exists(_PdfName)
            System.Threading.Thread.Sleep(500)
        End If


    End Sub

Attachments
aspect ratio
aspect ratio
ratio.jpg (47.8 KiB) Viewed 24627 times

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

Re: Print and printing parameters

Post by support » 04 Jun 2010, 17:00

Hello.
Unfortunately there is a problem within CAD Import .NET software that result in such situation when using prtForm.TypePage = CADImport.Printing.DrawingSize.Fit with some files. We will consider the problem and let you know when solution is ready.

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

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

Re: Print and printing parameters

Post by merco » 04 Jun 2010, 18:08

:cry:
but i need the DrawTextMeansGDIPlusMethods versions,
waht can i do know?

Post Reply