Search

Atalasoft Knowledge Base

HOWTO: Print using FileSystemImageSource

Administrator
DotImage

OUTDATED CONTENT WARNING

Please note that this article has been superseded by
HOWTO: Use an ImageSource with an AnnotatePrintDocument or ImagePrintDocument

Original Article left for reference only

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)
        {
            if (fsis..HasMoreImages())
            {
                e.Image = fsis.AcquireNext();
                e.HasMorePages = fsis.HasMoreImages();
            }
        }
 
        void print_AfterPrintPage(object sender, PrintImageEventArgs e)
        {
            fsis.Release(e.Image);
        }

VB.NET

Dim 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)
    If fsis.HasMoreImages() Then
        e.Image = fsis.AcquireNext()
        e.HasMorePages = fsis.HasMoreImages()
    End If
End Sub
 
Private Sub print_AfterPrintPage(ByVal sender As Object, ByVal e As PrintImageEventArgs)
     fsis.Release(e.Image)
End Sub

Original Article:
Q10310 - HOWTO: Print using FileSystemImageSource

Details
Last Modified: 5 Years Ago
Last Modified By: Tananda
Type: HOWTO
Article not rated yet.
Article has been viewed 736 times.
Options
Also In This Category