←Select platform

InsertPage Method

Summary
Inserts a new page into this RasterImage.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int InsertPage( 
   int index, 
   RasterImage image 
) 
- (NSInteger)insertPage:(LTRasterImage *)page atIndex:(NSInteger)index 
public int insertPage( 
   int index, 
   RasterImage image 
); 
public: 
int InsertPage(  
   int index, 
   RasterImage^ image 
)  
def InsertPage(self,index,image): 

Parameters

index
The 1-based index of the page from  image to insert. If  index is equal to -1, the page is inserted at the end. Use  index = 0 to insert the new page as the beginning (first).

image
The image to add.

Return Value

The 1-based index of the newly inserted page.

Remarks

This method pulls the current active page of  image and inserts into the current RasterImage object at index =  index. The number of pages in  image is decremented by one, if  image had only one page prior to calling this method, then the  image object is disposed of and should not be used afterwards.

The RasterImage object can hold multiple pages with different sizes. The AddPage, AddPages, InsertPage and InsertPages methods allows adding new pages to an existing RasterImage.

The RemovePageAt, RemovePages and RemoveAllPages methods allows removing existing pages from a RasterImage object.

The ReplacePage and ReplacePages methods allows replace existing pages in a RasterImage object.

The PageCount property holds the total number of pages in a RasterImage object while the Page property allows you to change the current active page.

The current active page (The page indicated by the Page property) is used by default when accessing the data of a RasterImage object unless otherwise indicated.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Dicom; 
using Leadtools.Drawing; 
using Leadtools.Controls; 
using Leadtools.Svg; 
 
 
public void PagesExample() 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
	codecs.Options.Load.AllPages = true; 
 
	string srcFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "eye.gif"); 
	string srcFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp"); 
 
	// Load the multi-page image 
	RasterImage srcImage = codecs.Load(srcFileName1); 
 
	// Show the number of pages in this file 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	// Show and change the active page 
	Console.WriteLine("Active page: {0}", srcImage.Page); 
	srcImage.Page = 3; 
	Console.WriteLine("Active page: {0}", srcImage.Page); 
	srcImage.Page = 1; 
 
	// Load a single page image and add it to the end 
	RasterImage pageImage = codecs.Load(srcFileName2); 
	Console.WriteLine("Adding a single page"); 
	srcImage.AddPage(pageImage); 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	// Load a multi page image and add a few pages to this image 
	pageImage = codecs.Load(srcFileName1); 
	Console.WriteLine("Adding multi-pages"); 
	srcImage.AddPages(pageImage, 1, 2); 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	// Insert a page in the middle 
	Console.WriteLine("Inserting a page"); 
	srcImage.InsertPage(4, pageImage); 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	// Insert the rest of the pages at the beginning 
	Console.WriteLine("Inserting pages"); 
	srcImage.InsertPages(0, pageImage, 1, -1); 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	// Remove the first page 
	Console.WriteLine("Removing a page"); 
	srcImage.RemovePageAt(1); 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	// Remove the last 3 pages 
	Console.WriteLine("Removing pages"); 
	srcImage.RemovePages(srcImage.PageCount - 3, -1); 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	// Remove all the pages (leaves 1) 
	Console.WriteLine("Removing all pages"); 
	srcImage.RemoveAllPages(); 
	Console.WriteLine("Pages in the image: {0}", srcImage.PageCount); 
 
	srcImage.Dispose(); 
	codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.