locked
want to print my current windows form RRS feed

  • Question

  • hi!

    I have a form which contains labels and picture.i tried this code to print.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            PrintPreviewDialog1.PrintPreviewControl.Document = PrintDocument1

            If PrintPreviewDialog1.ShowDialog = DialogResult.OK Then
                PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.ClientAreaOnly)
            End If

    my problem is
    1) i can tak print outi but its not clear (blurd)
    2)how to preview the form before taking print

    End Sub

    Monday, March 8, 2010 6:58 AM

Answers

  • can anybody suggest me?


    You have not posted any string printing code.  You are printing screen shots  To improve the print quality, print the text in the labels directly to the printer.
    • Proposed as answer by Chao Kuo Wednesday, March 10, 2010 10:45 AM
    • Marked as answer by Chao Kuo Friday, March 12, 2010 8:48 AM
    Monday, March 8, 2010 1:39 PM

All replies

  • Monday, March 8, 2010 7:28 AM
  • i already visited this page. my req. is i want to print current form. i have done also.

    how can i assign my form to printdialogprivew1.document

    then in print all letters are v blurred. not clear.  y and what to do?

    pls suggest.
    Monday, March 8, 2010 7:32 AM
  • I SOLVED my one problem. i can priview my document.

    the second problem is letters are v blurred/

    can anybody suggest for this/
    Monday, March 8, 2010 8:34 AM
  • Increase the form and font size and print to a reduced size.
    Monday, March 8, 2010 9:07 AM
  • can u pls tell how

    this is method which capture current form for print

     

    Private Sub PDoc_PrintPage(ByVal sender As System.Object, ByVal e As PrintPageEventArgs)

    Dim bmp As New Bitmap(Me.Width, Me.Height)

    Me.DrawToBitmap(bmp, New Rectangle(0, 0, bmp.Width, bmp.Height))

    'Takes the Snap of the Exact WindowForm size as Bitmap image

    e.Graphics.DrawImage(bmp, 0, 0)

    End Sub



    Monday, March 8, 2010 9:13 AM
  • Increase the form and font size and print to a reduced size.

    What don't you understand?

    Make everything bigger so when you print it you can draw to a reduced size.

    Or print the text directly to the printer.
    Monday, March 8, 2010 9:38 AM
  • i do understand.

    form is in maximized state.

    font size is already 14. i want the print in this size. 

    when i give print the text directly the text dislpalying as blurred.






    Monday, March 8, 2010 10:23 AM
  • i do understand.

    form is in maximized state.

    font size is already 14. i want the print in this size. 

    when i give print the text directly the text dislpalying as blurred.






    Monday, March 8, 2010 10:24 AM
  • form is in maximized state.

    font size is already 14. i want the print in this size. 







    Then you will have to live with the blurryness.  All you can do is experiment with the interpolation mode in the graphics.  Post the code you use to print text directly to the printer that results in blurred text.
    Monday, March 8, 2010 11:09 AM
  • Imports System.Drawing.Printing
    Public Class cvn_Invoicefrm_3
    
        Dim PrintDoc1 As New PrintDocument()
        Dim PPDlg1 As New PrintPreviewDialog()
    
        Public Sub New()
    
            ' This call is required by the Windows Form Designer.
            InitializeComponent()
    
            PPDlg1.Document = PrintDoc1
            PrintDoc1.OriginAtMargins = True
    
            'To set or Get the Position of a Graphic Object    
    
            AddHandler PrintDoc1.PrintPage, AddressOf PDoc_PrintPage
            ' Add any initialization after the InitializeComponent() call.
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            'When Print Button Clicks, Image will be show & Ready to Print    
            PrintDoc1.Print()
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    
            ' When PrintPreview Button Clicks            
            PPDlg1.ShowDialog()
    
        End Sub
    
        Private Sub PDoc_PrintPage(ByVal sender As System.Object, ByVal e As PrintPageEventArgs)
    
            Dim bmp As New Bitmap(Me.Width, Me.Height)
    
            Me.DrawToBitmap(bmp, New Rectangle(0, 0, bmp.Width, bmp.Height))
    
            'Takes the Snap of the Exact WindowForm size as Bitmap image      
    
            e.Graphics.DrawImage(bmp, 0, 0)
    
        End Sub
    
    End Class
    

    i have only labels.

    i am getting values from database and assigning to labels.

    concept of this is the filled form needs to print when users click on button.

    pls guide accordingly.
    Monday, March 8, 2010 11:35 AM
  • can anybody suggest me?

    Monday, March 8, 2010 12:25 PM
  • can anybody suggest me?


    You have not posted any string printing code.  You are printing screen shots  To improve the print quality, print the text in the labels directly to the printer.
    • Proposed as answer by Chao Kuo Wednesday, March 10, 2010 10:45 AM
    • Marked as answer by Chao Kuo Friday, March 12, 2010 8:48 AM
    Monday, March 8, 2010 1:39 PM
  • Hello,
    Please reference Martin's answer in this link http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/9e25f8a0-fcbc-4a8a-9134-55ad2b718887/, it illustrate why the it is blur and how to resolve it.
    Thanks
    Chao

    Wednesday, March 10, 2010 10:35 AM