locked
how to export a vb.net windows form into a pdf format RRS feed

  • Question

  • hello guys,

    i m working on vb.net just few days back and i have a problem right now that i want to export a form into a pdf format and i don't know how to do this?

    will anybody help me, plz

    thanx in advance

    regards,
    N Akhtar
     
    • Moved by Figo Fei Friday, July 11, 2008 4:19 AM move to VB g
    Tuesday, July 8, 2008 7:51 AM

Answers

  • n akhtar said:

    i m working on vb.net just few days back and i have a problem right now that i want to export a form into a pdf format and i don't know how to do this?



    Hi N Akhtar,

    Here is one solution:
    Step 1: Use CopyFromScreen method to capture entire Form screenshot, thus get one image.
    Imports System.Drawing.Imaging  
     
    Public Class Form1  
     
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
            Dim bmpScreenshot As Bitmap = New Bitmap(Width, Height, PixelFormat.Format32bppArgb)  
            ' Create a graphics object from the bitmap  
            Dim gfxScreenshot As Graphics = Graphics.FromImage(bmpScreenshot)  
            ' Take a screenshot of the entire Form1  
            gfxScreenshot.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, Me.Size, CopyPixelOperation.SourceCopy)  
            ' Save the screenshot   
            bmpScreenshot.Save("D:\Form1.jpg", ImageFormat.Jpeg)  
        End Sub 
     
    End Class 
    Trackback: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2279810&SiteID=1

    Step 2: Conver the Form screenshot image to pdf format in VB.NET by using related components to PDF.

       PDF Vision.Net
      
    http://www.sautinsoft.com/products/pdf-vision/index.php


       PDF Creator Pilot
      
    http://www.colorpilot.com/pdfcreatorpilotmanual/How_to_convert_image_to_PDF_using_VB_NET.html


    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    Best regards,
    Martin Xie
    Monday, July 14, 2008 11:09 AM

All replies

  • n akhtar said:

    i m working on vb.net just few days back and i have a problem right now that i want to export a form into a pdf format and i don't know how to do this?



    Hi N Akhtar,

    Here is one solution:
    Step 1: Use CopyFromScreen method to capture entire Form screenshot, thus get one image.
    Imports System.Drawing.Imaging  
     
    Public Class Form1  
     
        Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
            Dim bmpScreenshot As Bitmap = New Bitmap(Width, Height, PixelFormat.Format32bppArgb)  
            ' Create a graphics object from the bitmap  
            Dim gfxScreenshot As Graphics = Graphics.FromImage(bmpScreenshot)  
            ' Take a screenshot of the entire Form1  
            gfxScreenshot.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, Me.Size, CopyPixelOperation.SourceCopy)  
            ' Save the screenshot   
            bmpScreenshot.Save("D:\Form1.jpg", ImageFormat.Jpeg)  
        End Sub 
     
    End Class 
    Trackback: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2279810&SiteID=1

    Step 2: Conver the Form screenshot image to pdf format in VB.NET by using related components to PDF.

       PDF Vision.Net
      
    http://www.sautinsoft.com/products/pdf-vision/index.php


       PDF Creator Pilot
      
    http://www.colorpilot.com/pdfcreatorpilotmanual/How_to_convert_image_to_PDF_using_VB_NET.html


    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    Best regards,
    Martin Xie
    Monday, July 14, 2008 11:09 AM
  • thanks a lot martin


    the post was good and thanks again


    regards
    N Akhtar
    Thursday, July 17, 2008 8:03 AM
  • Hi N Akhtar,

    You're welcome.  Glad to help you.  
    :-)
    Thursday, July 17, 2008 12:46 PM
  • Thank you that it's Extremely helpful. After referring a lot of stuff i came to declaration that it's best doing your way. Like=> Jpeg to PDF.

    But I need small help. This captures The entire form with toolbar and window. Can you please say me how can this be configured so i can get only form page.

    Saturday, April 6, 2013 9:25 AM