Hi to all,

I need to print a form in vb.net,but the problem is my form size is 1382, 784.If i print a form means it cuts other side..Any idea or reference link to print a form in full size are appreciated.

I assume you're using the printform control from the vb powerpack. Did you try setting the landscape setting to true? PrintForm1.PrinterSettings.DefaultPageSettings.Landscape = True

In case that doesn't work for you here's some code that will print whatever portion of your form that will fit on your screen:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
    CaptureScreen()
    PrintDocument1.DefaultPageSettings.Landscape = True
    PrintDocument1.DefaultPageSettings.Margins = New Printing.Margins(0, 0, 0, 0)
    PrintDocument1.Print()
End Sub

Dim memoryImage As Bitmap

Private Sub CaptureScreen()
    Dim myGraphics As Graphics = Me.CreateGraphics()
    Dim s As Size = Me.Size
    memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
    Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
    memoryGraphics.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, s)
End Sub

Private Sub printDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

    Dim pagerec As New RectangleF(e.PageSettings.PrintableArea.X, e.PageSettings.PrintableArea.Y, e.PageSettings.PrintableArea.Height, e.PageSettings.PrintableArea.Width)

    e.Graphics.DrawImage(memoryImage, pagerec, New Rectangle(Me.Location, Me.Size), GraphicsUnit.Pixel)

End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.