Leadtools.Document Deprecated as of v16. Refer to: Leadtools.Forms.Ocr | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
AddPage Method
See Also  Example
Leadtools.Document Namespace > RasterDocumentEngine Class : AddPage Method



image
An RasterImage object that references the new page to be inserted into the internal OCR list of pages.
pageIndex
Position in the list of pages at which to insert the new page. Use -1 to append the page to the end of the list.Use zero-based indexing. For example, if there are 10 pages in the list, the index of the last page is 9. If you insert a page within the list, the indices of other pages will change automatically to accommodate the insertion.
image
An RasterImage object that references the new page to be inserted into the internal OCR list of pages.
pageIndex
Position in the list of pages at which to insert the new page. Use -1 to append the page to the end of the list.Use zero-based indexing. For example, if there are 10 pages in the list, the index of the last page is 9. If you insert a page within the list, the indices of other pages will change automatically to accommodate the insertion.
Adds a new page to the OCR document.

Syntax

Visual Basic (Declaration) 
Public Sub AddPage( _
   ByVal image As RasterImage, _
   ByVal pageIndex As Integer _
) 
Visual Basic (Usage)Copy Code
Dim instance As RasterDocumentEngine
Dim image As RasterImage
Dim pageIndex As Integer
 
instance.AddPage(image, pageIndex)
C# 
public void AddPage( 
   RasterImage image,
   int pageIndex
)
C++/CLI 
public:
void AddPage( 
   RasterImage image,
   int pageIndex
) 

Parameters

image
An RasterImage object that references the new page to be inserted into the internal OCR list of pages.
pageIndex
Position in the list of pages at which to insert the new page. Use -1 to append the page to the end of the list.Use zero-based indexing. For example, if there are 10 pages in the list, the index of the last page is 9. If you insert a page within the list, the indices of other pages will change automatically to accommodate the insertion.

Example

Visual BasicCopy Code
Public Sub AddPageExample()
   ' Load an image
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ocr1.tif")

   ' Note that this is a sample key, which will not work in your toolkit
   RasterSupport.Unlock(Leadtools.RasterSupportType.Ocr, "TestKey")

   Dim rasterDocument As RasterDocumentEngine
   rasterDocument = RasterDocumentEngine.Instance
   rasterDocument.Startup()

   Try
      rasterDocument.AddPage(image, 0)
      MessageBox.Show("The engine added a new page to the Document")
   Catch ex As Exception
      MessageBox.Show(ex.Message)
   End Try

   Dim pageCount As Integer = rasterDocument.PageCount
   Dim buffer As String = String.Format("The Number of Pages in the Document is: {0)", pageCount)
   MessageBox.Show(buffer)

   RasterCodecs.Shutdown()
   rasterDocument.Shutdown()
End Sub
C#Copy Code
public void AddPageExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ocr1.tif"); 
 
   // Note that this is a sample key, which will not work in your toolkit 
   RasterSupport.Unlock(Leadtools.RasterSupportType.Ocr, "TestKey"); 
   RasterDocumentEngine rasterDocument; 
   rasterDocument = RasterDocumentEngine.Instance; 
   rasterDocument.Startup(); 
 
   try 
   { 
      rasterDocument.AddPage(image, 0); 
      MessageBox.Show("The engine added a new page to the Document"); 
   } 
   catch (Exception ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
 
   int pageCount = rasterDocument.PageCount; 
   string buffer = string.Format("The Number of Pages in the Document is: {0)", pageCount); 
   MessageBox.Show(buffer); 
 
   RasterCodecs.Shutdown(); 
}

Remarks

This method converts the inserted page so it matches the OCR requirements. In addition, this method checks the color order for each loaded image. If any image color order is inverted (i.e. white to black) then the method will convert the color order to be normal (i.e. black to white).
For more information, refer to Working with Pages.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also

The Leadtools.Document namespace is deprecated and no longer supported as of LEADTOOLS v16. For v16 and later, please refer to: Leadtools.Forms.Ocr. This documentation is retained for v15 and earlier informational use only.