locked
printing bitmap image. RRS feed

  • Question

  • HI,

    I am working on WPF + C# . I have 1 bitmap image. Please any 1 tell me , how I print bitmap image in PDF- format and also through printer which will give me high quality print ? Here I consider resizing bitmap image then pass it to print?  

    • Edited by anupsapate Wednesday, February 15, 2012 11:43 AM
    • Changed type anupsapate Wednesday, February 15, 2012 11:48 AM
    • Changed type anupsapate Wednesday, February 15, 2012 11:48 AM
    Wednesday, February 15, 2012 5:20 AM

Answers

  • Use the code below to print a bitmap to a print document which is then sent to PDF-XChange 4.0. PDF-XChange 4.0 is selected as the printer when the print dialog is shown.

    Use a filename in the Bitmap Class constructor to load an image from the file system. Here I have created an elipse on the bitmap.

    If you want to print directly to the PDF without showing the print dialog then you will have to configure PDF-XChange 4.0 to print to a file.

    Public Class PrintForm
    
        Private Sub Print_Click(sender As System.Object, e As System.EventArgs) Handles Print.Click
    
            Dim pdoc As New Printing.PrintDocument
            Dim pdlg As New PrintDialog
    
            pdlg.ShowDialog()
            pdoc.PrinterSettings.PrinterName = pdlg.PrinterSettings.PrinterName
            AddHandler pdoc.PrintPage, AddressOf PrintPage
            pdoc.Print()
    
        End Sub
    
        Public Sub PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
    
            Dim b As New Bitmap(200, 200)
            Dim gr As Graphics = Graphics.FromImage(b)
    
            gr.DrawEllipse(New Pen(Brushes.AliceBlue), New Rectangle(0, 0, 200, 200))
            e.Graphics.DrawImage(b, New Point(0, 0))
    
        End Sub
    
    End Class
    Hope this helps :)
    • Proposed as answer by VallarasuS Friday, February 17, 2012 4:50 PM
    • Marked as answer by Sheldon _Xiao Tuesday, March 6, 2012 7:24 AM
    Friday, February 17, 2012 11:20 AM

All replies

  • No I want to print bitmap in "PDF-XChange 4.0" which is another option for printing.
    Thursday, February 16, 2012 12:51 PM
  • Thanks
    Friday, February 17, 2012 3:54 PM
  • Hi anupsapate,
     
    I am marking your issue as "Answered", if you have new findings about your issue, please let me know.
     

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 6, 2012 7:24 AM