Home : Printing : Print a Cover Page with ImagePrintDocument
Q10297 - HOWTO: Print a Cover Page with ImagePrintDocument

DotImage’s Canvas object allows the user to draw objects onto an AtalaImage. Combining this with the ImagePrintDocument object, the user can create dynamic printed content. The snippets below demonstrate how to add a front title page to the document in the printer.

C#

private void PrintWithTitlePage(ImageCollection imgcol)

{

    Dpi Resolution = new Dpi(100, 100, ResolutionUnit.DotsPerInch);

    AtalaImage img = GenerateTitlePage(Resolution, "This is my Title");

    imgcol.Insert(0, img);

    ImagePrintDocument print = new ImagePrintDocument(imgcol);

    print.Print();

}

 

private AtalaImage GenerateTitlePage(Dpi Resolution, string Title)

{

    AtalaImage img = new AtalaImage((int)(8.5 * Resolution.X),(int)(11 * Resolution.Y), PixelFormat.Pixel1bppIndexed, Color.White);

    Canvas c = new Canvas(img);

    c.DrawText(Title, new Rectangle(new Point(0,(int)(.4*img.Size.Height)),      img.Size), new Font(FontFamily.GenericSansSerif,30),new AtalaPen(Color.Black).Fill,new TextFormat(TextAlignment.Center));

    return img;

}

 

VB.NET

Private Sub PrintWithTitlePage(ByVal imgcol As ImageCollection)

    Dim Resolution As New Dpi(100, 100, ResolutionUnit.DotsPerInch)

    Dim img As AtalaImage = GenerateTitlePage(Resolution, "This is my Title")

    imgcol.Insert(0, img)

    Dim print As New ImagePrintDocument(imgcol)

    print.Print()

End Sub

 

Private Function GenerateTitlePage(ByVal Resolution As Dpi, ByVal Title As String) As AtalaImage

    Dim img As New AtalaImage(CInt((8.5 * Resolution.X)), CInt((11 * Resolution.Y)), PixelFormat.Pixel1bppIndexed, Color.White)

    Dim c As New Canvas(img)

    c.DrawText(Title, New Rectangle(New Point(0, CInt((0.4 * img.Size.Height))), img.Size), New Font(FontFamily.GenericSansSerif, 30), New AtalaPen(Color.Black).Fill, New TextFormat(TextAlignment.Center))

    Return img

End Function

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