Click or drag to resize

ImageCompositePrintDocument Class

Allows multiple images to be printed per page at typical metric and English photo sizes.
Inheritance Hierarchy
SystemObject
  SystemMarshalByRefObject
    System.ComponentModelComponent
      System.Drawing.PrintingPrintDocument
        Atalasoft.Imaging.WinControlsImageCompositePrintDocument

Namespace:  Atalasoft.Imaging.WinControls
Assembly:  Atalasoft.dotImage.WinControls (in Atalasoft.dotImage.WinControls.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public class ImageCompositePrintDocument : PrintDocument

The ImageCompositePrintDocument type exposes the following members.

Constructors
  NameDescription
Public methodImageCompositePrintDocument
Instantiates a new instance of the ImageCompositePrintDocument class.
Public methodImageCompositePrintDocument(CompositePrintLayout)
Instantiates a new instance of the ImageCompositePrintDocument class specifying the page layout.
Top
Properties
  NameDescription
Protected propertyCanRaiseEvents
Gets a value indicating whether the component can raise an event.
(Inherited from Component.)
Public propertyCaptionAlignment
Gets or sets the horizontal alignment of the caption text.
Public propertyCaptionColor
Gets or sets the color of the caption text.
Public propertyCaptionFont
Gets or sets the font properties of the caption text.
Public propertyContainer
Gets the IContainer that contains the Component.
(Inherited from Component.)
Public propertyCropImageToFit
Gets or sets a value indicating if the image is cropped or resized to fit the aspect ratio of the photo print.
Public propertyDefaultPageSettings
Gets or sets page settings that are used as defaults for all pages to be printed.
(Inherited from PrintDocument.)
Protected propertyDesignMode
Gets a value that indicates whether the Component is currently in design mode.
(Inherited from Component.)
Public propertyDocumentName
Gets or sets the document name to display (for example, in a print status dialog box or printer queue) while printing the document.
(Inherited from PrintDocument.)
Protected propertyEvents
Gets the list of event handlers that are attached to this Component.
(Inherited from Component.)
Public propertyLayout
Gets or sets the composite photo print layout that will be printed on each page.
Public propertyOriginAtMargins
Gets or sets a value indicating whether the position of a graphics object associated with a page is located just inside the user-specified margins or at the top-left corner of the printable area of the page.
(Inherited from PrintDocument.)
Public propertyPrintController
Gets or sets the print controller that guides the printing process.
(Inherited from PrintDocument.)
Public propertyPrinterSettings
Gets or sets the printer that prints the document.
(Inherited from PrintDocument.)
Public propertySite
Gets or sets the ISite of the Component.
(Inherited from Component.)
Top
Methods
  NameDescription
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodDispose
Releases all resources used by the Component.
(Inherited from Component.)
Protected methodDispose(Boolean)
Releases the unmanaged resources used by the Component and optionally releases the managed resources.
(Inherited from Component.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection.
(Inherited from Component.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Protected methodGetService
Returns an object that represents a service provided by the Component or by its Container.
(Inherited from Component.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodMemberwiseClone(Boolean)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.)
Protected methodOnAfterPrintImage
Protected methodOnBeginPrint (Overrides PrintDocumentOnBeginPrint(PrintEventArgs).)
Protected methodOnEndPrint
Raises the EndPrint event. It is called when the last page of the document has printed.
(Inherited from PrintDocument.)
Protected methodOnPrintImage
Protected methodOnPrintPage (Overrides PrintDocumentOnPrintPage(PrintPageEventArgs).)
Protected methodOnQueryPageSettings
Raises the QueryPageSettings event. It is called immediately before each PrintPage event.
(Inherited from PrintDocument.)
Public methodPrint
Starts the document's printing process.
(Inherited from PrintDocument.)
Public methodToString
Provides information about the print document, in string form.
(Inherited from PrintDocument.)
Top
Events
  NameDescription
Public eventCode exampleAfterPrintImage
Occurs after a specific image is printed during the printing process.
Public eventBeginPrint
Occurs when the Print method is called and before the first page of the document prints.
(Inherited from PrintDocument.)
Public eventDisposed
Occurs when the component is disposed by a call to the Dispose method.
(Inherited from Component.)
Public eventEndPrint
Occurs when the last page of the document has printed.
(Inherited from PrintDocument.)
Public eventCode examplePrintImage
Occurs before an image is printed during the printing process.
Public eventPrintPage
Occurs when the output to print for the current page is needed.
(Inherited from PrintDocument.)
Public eventQueryPageSettings
Occurs immediately before each PrintPage event.
(Inherited from PrintDocument.)
Top
Remarks

This component requires the PrintImage event to be handled (or OnPrintImage(PrintCompositeEventArgs) method overridden). In the event handler, pass an AtalaImage into the PrintCompositeEventArgs to be printed. Set the HasMorePages property to true when there are more images to print.

Minimum page margins will be used when calculating the image position. You may override the position and size of the printed image by changing the ImageBounds property of the PrintCompositeEventArgs. The image will always be rotated to fit.

A caption can be printed beneath each image by setting the Caption property of PrintCompositeEventArgs.

By default, images will be cropped to fit the aspect ratio of the printed size. However setting the CropImageToFit property to false will instead scale the image to fit the image bounds, keeping the original aspect ratio of the image.

Examples
Composite Print Events (C#)
private string[] _folders;

//handle this event to tell the printer component what images to print
private void imageCompositePrintDocument1_PrintImage(object sender, Atalasoft.Imaging.WinControls.PrintCompositeEventArgs e)
{
    if (_folders != null && _folders.Length > e.ImageIndex)
    {
        //specify the image to print
        e.Image = new AtalaImage(_folders[e.ImageIndex]);
        //specify the caption of the image
        e.Caption = System.IO.Path.GetFileName(_folders[e.ImageIndex]);
    }

    //tell Print Document if there are more images/pages to print after this one
    if (e.ImageIndex >= _folders.Length - 1)
        e.HasMorePages = false;
    else
        e.HasMorePages = true;
}

//handle this event to dispose the image that's no longer needed
private void imageCompositePrintDocument1_AfterPrintImage(object sender, Atalasoft.Imaging.WinControls.PrintCompositeEventArgs e)
{
    if (e.Image != null)
        e.Image.Dispose();
}

//print the images
private void btnPrint_Click(object sender, System.EventArgs e)
{
    if (this.printDialog1.ShowDialog(this) == DialogResult.OK)
    {
        //get images from a folder
        _folders = System.IO.Directory.GetFiles("c:\\photos", "*.jpg");
        this.imageCompositePrintDocument1.Print();
    }
}
Composite Print Events (Visual Basic)
Private _folders() As String

'handle this event to tell the printer component what images to print 
Private  Sub imageCompositePrintDocument1_PrintImage(ByVal sender As Object, ByVal e As Atalasoft.Imaging.WinControls.PrintCompositeEventArgs) Handles imageCompositePrintDocument1.PrintImage
    If Not _folders Is Nothing And _folders.Length > e.ImageIndex Then
        'specify the image to print 
        e.Image = New AtalaImage(_folders(e.ImageIndex)) 
        'specify the caption of the image 
        e.Caption = System.IO.Path.GetFileName(_folders(e.ImageIndex))
    End If

    'tell Print Document if there are more images/pages to print after this one 
    If e.ImageIndex >= _folders.Length - 1 Then
        e.HasMorePages = False
    Else 
        e.HasMorePages = True
    End If
End Sub

'handle this event to dispose the image that's no longer needed 
Private  Sub imageCompositePrintDocument1_AfterPrintImage(ByVal sender As Object, ByVal e As Atalasoft.Imaging.WinControls.PrintCompositeEventArgs) Handles imageCompositePrintDocument1.AfterPrintImage
    If Not e.Image Is Nothing Then
        e.Image.Dispose()
    End If
End Sub

'print the images 
Private  Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
    If Me.printDialog1.ShowDialog(Me) = DialogResult.OK Then
        'get images from a folder 
        _folders = System.IO.Directory.GetFiles("c:\photos", "*.jpg") 
        Me.imageCompositePrintDocument1.Print()
    End If
End Sub
See Also