Home : Printing : Print using FileSystemImageSource
Q10310 - HOWTO: Print using FileSystemImageSource

Using a FileSystemImageSource to print is very straight forward. Initialize the ImageSource. Use the events GetImage and AfterPrintPage to give the printer the image and tell it when to stop, respectively. The sample below is the simplest way to use a FileSystemImageSource to print:

C#

    fsis = new FileSystemImageSource(open.FileName, true);

    ImagePrintDocument print = new ImagePrintDocument();

    print.AfterPrintPage += new PrintImageEventHandler(print_AfterPrintPage);

    print.GetImage += new PrintImageEventHandler(print_GetImage);

    print.Print();

 

        void print_GetImage(object sender, PrintImageEventArgs e)

        {

            e.Image = fsis.AcquireNext();

        }

 

        void print_AfterPrintPage(object sender, PrintImageEventArgs e)

        {

            e.HasMorePages = fsis.HasMoreImages();

        }

VB.NET

 

fsis = New FileSystemImageSource(open.FileName, True)

Dim print As New ImagePrintDocument()

AddHandler print.AfterPrintPage, AddressOf print_AfterPrintPage

AddHandler print.GetImage, AddressOf print_GetImage

print.Print()

 

Private Sub print_GetImage(ByVal sender As Object, ByVal e As PrintImageEventArgs)

    e.Image = fsis.AcquireNext()

End Sub

 

Private Sub print_AfterPrintPage(ByVal sender As Object, ByVal e As PrintImageEventArgs)

    e.HasMorePages = fsis.HasMoreImages()

End Sub

 

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved