Search

Atalasoft Knowledge Base

HOWTO: Number a multipage TIFF

Administrator
DotImage

DEPRECATION WARNING

Please note that using the Images collection of a WorkspaceViewer or AnnotateViewer is (like using an ImageCollection directly) a very memory inefficient approach. Each image in an ImageCollection requires a contiguous block of memory height * width * pixel_depth and all need to be in memory at once.

Please consider using the DocumentViewer or DocumentAnnotationViewer instead

Original Content

The following example code is a simple way to add page numbers to a multipage TIFF.

Note: This code assumes ws is a Workspace or WorkspaceViewer.

C#

// Prepare the drawing objects.
SolidFill fill = new SolidFill(Color.Black);
Font font = new Font("Verdana", 12);
int num = 1;

// Loop through the pages, adding a number to the top right corner.
foreach (AtalaImage image in ws.Images)
{
    Canvas canvas = new Canvas(image);
    string strNum = num.ToString();

    // Calculate the position for the page number.
    SizeF numSize = Canvas.CalculateTextSize(strNum, font);
    Point position = new Point(Convert.ToInt32(image.Width - numSize.Width - 20), 20);

    // Draw it.
    canvas.DrawText(strNum, position, font, fill);
    num++;
}

VB.NET

' Prepare the drawing objects.
Dim fill As SolidFill =  New SolidFill(Color.Black) 
Dim font As Font =  New Font("Verdana",12) 
Dim num As Integer =  1 
 
' Loop through the pages, adding a number to the top right corner.
Dim image As AtalaImage
For Each image In ws.Images
    Dim canvas As Canvas =  New Canvas(image) 
    Dim strNum As String =  num.ToString() 
 
    ' Calculate the position for the page number.
    Dim numSize As SizeF =  Canvas.CalculateTextSize(strNum,font) 
    Dim position As Point =  New Point(Convert.ToInt32(image.Width - numSize.Width - 20),20) 
 
    ' Draw it.
    canvas.DrawText(strNum, position, font, fill)
    num = num + 1
Next

Original Article:
Q10137 - HOWTO: Numbering a multipage TIFF

Details
Last Modified: Last Month
Last Modified By: Administrator
Type: HOWTO
Article not rated yet.
Article has been viewed 42 times.
Options
Also In This Category