LEADTOOLS Annotations (Leadtools.Annotations assembly)
LEAD Technologies, Inc

DeletePage(String,Int32) Method

Example 





Name of the annotation file.
Number of the page to delete. The page number is 1-based. Therefore, the first page is page 1, the second page is page 2, etc.
Deletes a page from an annotation file containing multiple pages.
Syntax
public void DeletePage( 
   string fileName,
   int page
)
'Declaration
 
Public Overloads Sub DeletePage( _
   ByVal fileName As String, _
   ByVal page As Integer _
) 
'Usage
 
Dim instance As AnnCodecs
Dim fileName As String
Dim page As Integer
 
instance.DeletePage(fileName, page)
public void DeletePage( 
   string fileName,
   int page
)
 function Leadtools.Annotations.AnnCodecs.DeletePage(String,Int32)( 
   fileName ,
   page 
)
public:
void DeletePage( 
   String^ fileName,
   int page
) 

Parameters

fileName
Name of the annotation file.
page
Number of the page to delete. The page number is 1-based. Therefore, the first page is page 1, the second page is page 2, etc.
Remarks

This method can be used to remove annotation pages from a multi-page annotation file. The page number is 1-based. Therefore, the first page is page 1, the second page is page 2, and so on. This method can be used for all LEAD annotation file formats. To determine the format for a particular LEAD annotation file, use GetInformation(String,AnnCodecsInformation).

Note, you cannot delete a page from an annotation file that has only 1 page.

Example
 
Public Sub AnnCodecs_DeletePage(ByVal fileName As String)
   ' create a new annotation container
   Dim container As AnnContainer = New AnnContainer()
   ' add a few objects into the container

   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)
   rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))
   rectObj.Brush = Nothing
   container.Objects.Add(rectObj)

   Dim lineObj As AnnLineObject = New AnnLineObject()
   lineObj.StartPoint = New AnnPoint(100, 100, AnnUnit.Pixel)
   lineObj.EndPoint = New AnnPoint(200, 200, AnnUnit.Pixel)
   lineObj.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))
   container.Objects.Add(lineObj)

   ' create a new AnnCodecs class
   Dim codecs As AnnCodecs = New AnnCodecs()

   ' save this container into a file
   ' save the objects in this container
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite)

   ' get information about the file
   Dim information As AnnCodecsInformation = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))

   ' save the objects again (as a second page)
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 2, AnnCodecsSavePageMode.Insert)

   ' get information about the file
   information = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))

   ' delete the first page
   codecs.DeletePage(fileName, 1)

   ' get information about the file
   information = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))
End Sub
public void AnnCodecs_DeletePage(string fileName)
{
   // create a new annotation container
   AnnContainer container = new AnnContainer();
   // add a few objects into the container

   AnnRectangleObject rectObj = new AnnRectangleObject();
   rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);
   rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));
   rectObj.Brush = null;
   container.Objects.Add(rectObj);

   AnnLineObject lineObj = new AnnLineObject();
   lineObj.StartPoint = new AnnPoint(100, 100, AnnUnit.Pixel);
   lineObj.EndPoint = new AnnPoint(200, 200, AnnUnit.Pixel);
   lineObj.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));
   container.Objects.Add(lineObj);

   // create a new AnnCodecs class
   AnnCodecs codecs = new AnnCodecs();

   // save this container into a file
   // save the objects in this container
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite);

   // get information about the file
   AnnCodecsInformation information = new AnnCodecsInformation();
   codecs.GetInformation(fileName, information);
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));

   // save the objects again (as a second page)
   codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 2, AnnCodecsSavePageMode.Insert);

   // get information about the file
   information = new AnnCodecsInformation();
   codecs.GetInformation(fileName, information);
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));

   // delete the first page
   codecs.DeletePage(fileName, 1);

   // get information about the file
   information = new AnnCodecsInformation();
   codecs.GetInformation(fileName, information);
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

AnnCodecs Class
AnnCodecs Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.