Results 1 to 2 of 2

Thread: [2005] print image

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    719

    [2005] print image

    how to print image base on its location..

    "C:\imgTest.jpg"

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] print image

    All .NET printing is done in basically the same way. You create a PrintDocument, call its Print method and handle its PrintPage event. In the PrintPage event handler you draw your printed output onto the GDI+ canvas using the e.Graphics property. To draw an Image using GDI+ you can DrawImage. There are plenty of printing examples on the forum, the Web and in the MSDN documentation so I'm not going to provide another one here. A quick search will turn up plenty.

    Also, to create the Image object in the first place you should call Image.FromFile. You must make sure you dispose the Image object when you're done though. The easiest way to do that is with a Using block:
    vb.net Code:
    1. Using img As Image = Image.FromFile("file path here")
    2.     'Use img here.
    3. End Using
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width