The RemoveChild method deletes the child bookmark at the specified position.
Public Function RemoveChild(Index As Integer) As Boolean
public bool RemoveChild(int Index)
Index
0 based index where the child bookmark to be deleted.
Member of Amyuni.PDFCreator.IacBookmark.
Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Creator .NET Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B"
' Initialize library
' This should be done once
acPDFCreatorLib.Initialize()
' set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode)
' Create a new PDF document
Dim doc As New Amyuni.PDFCreator.IacDocument()
' Create the Bookmarks
Dim root As Amyuni.PDFCreator.IacBookmark = doc.RootBookmark
' Insert bookmark at the top level
Dim parentBookmark As Amyuni.PDFCreator.IacBookmark = root.InsertChild(0, "Parent bookmark", "")
' Create a 5 page with a text object And Page BookMark
Dim pageCount As Integer = 5
For i = 1 To pageCount
' Create a Text
With doc.GetPage(i).CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text" + i.ToString)
.Attribute("Left").Value = 1000
.Attribute("Right").Value = 5000
.Attribute("Top").Value = 0
.Attribute("Bottom").Value = 4000
.Attribute("BorderColor").Value = &HFF00FF
.Attribute("BorderWidth").Value = Amyuni.PDFCreator.IacBorderWidth.acBorderWidthDouble
.Attribute("Text").Value = "Amyuni Technologies " + i.ToString
End With
' Create the current Page Bookmark and it inserts at the end
Dim bookmarkText As String = "Bookmark to page " + i.ToString
Dim currentPageBookmark As Amyuni.PDFCreator.IacBookmark = parentBookmark.InsertChild(parentBookmark.Count, bookmarkText, "Text" + i.ToString)
' changing properties
currentPageBookmark.TitleBold = True
currentPageBookmark.TitleColor = System.Drawing.Color.DarkGreen
currentPageBookmark.TitleItalic = True
' Add page
doc.AddPage(i)
Next
' Show the bookmark 1
doc.ReachBookmark("Bookmark to page 1")
' Create new stream object
Dim fileWrite As System.IO.Stream = System.IO.File.OpenWrite("C:\temp\withBookmarks.pdf")
' Save PDF file
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView)
' Close the stream
fileWrite.Close()
' Getting the parentBookmark
parentBookmark = doc.RootBookmark.GetChild(0)
' Counting Bookmarks
Console.WriteLine("Number of BookMark: {0}", parentBookmark.Count)
' Getting the first bookmark
Dim pageBookmark As Amyuni.PDFCreator.IacBookmark = parentBookmark.GetChild(1)
' remove Child
parentBookmark.RemoveChild(2)
' Getting the title
Console.WriteLine("Title BookMark: {0}", pageBookmark.Title)
' displays the title of the parent.
Console.WriteLine("Title Parent BookMark: {0}", pageBookmark.Parent.Title)
' Create new stream object
fileWrite = System.IO.File.OpenWrite("C:\temp\withBookmarks2.pdf")
' Save PDF file
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView)
' Close the stream
fileWrite.Close()
' Dispose the bookmark Objects
parentBookmark.Dispose()
root.Dispose()
' terminate library to free resources
acPDFCreatorLib.Terminate()
End Sub
static void Sample()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Creator .NET Evaluation";
const string strActivationCode = "07EFCDAB0100010025C3B7B351579FF94C49112EAF7368612744C7237C2F6A215A53E83A9ECCFFE54C52063CB05338BDE555773D7B1B";
// Initialize library
// This should be done once
acPDFCreatorLib.Initialize();
// set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey(strLicenseTo, strActivationCode);
// Create a new PDF document
Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument();
// Create the Bookmarks
Amyuni.PDFCreator.IacBookmark root = doc.RootBookmark;
// Insert bookmark at the top level
Amyuni.PDFCreator.IacBookmark parentBookmark = root.InsertChild(0, "Parent bookmark", "");
// Create a 5 page with a text object And Page BookMark
int pageCount = 5;
for (int i = 1; i <= pageCount; i++)
{
// Create a Text
using (Amyuni.PDFCreator.IacObject oText = doc.GetPage(i).CreateObject(Amyuni.PDFCreator.IacObjectType.acObjectTypeText, "Text" + i.ToString()))
{
oText.Attribute("Left").Value = 1000;
oText.Attribute("Right").Value = 5000;
oText.Attribute("Top").Value = 0;
oText.Attribute("Bottom").Value = 4000;
oText.Attribute("BorderColor").Value = 0xFF00FF;
oText.Attribute("BorderWidth").Value = Amyuni.PDFCreator.IacBorderWidth.acBorderWidthDouble;
oText.Attribute("Text").Value = "Amyuni Technologies " + i.ToString();
}
// Create the current Page Bookmark and it inserts at the end
string bookmarkText = "Bookmark to page " + i.ToString();
Amyuni.PDFCreator.IacBookmark currentPageBookmark = parentBookmark.InsertChild(parentBookmark.Count, bookmarkText, "Text" + i.ToString());
// changing properties
currentPageBookmark.TitleBold = true;
currentPageBookmark.TitleColor = System.Drawing.Color.DarkGreen;
currentPageBookmark.TitleItalic = true;
// Add page
doc.AddPage(i);
}
// Show the bookmark 1
doc.ReachBookmark("Bookmark to page 1");
// Create new stream object
System.IO.FileStream fileWrite = new System.IO.FileStream("C:\\temp\\withBookmarks.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.Read);
// Save PDF File
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);
// Close the stream
fileWrite.Close();
// Getting the parentBookmark
parentBookmark = doc.RootBookmark.GetChild(0);
// Counting Bookmarks
Console.WriteLine("Number of BookMark: {0}", parentBookmark.Count);
// Getting the first bookmark
Amyuni.PDFCreator.IacBookmark pageBookmark = parentBookmark.GetChild(1);
// remove Child
parentBookmark.RemoveChild(2);
// Getting the title
Console.WriteLine("Title BookMark: {0}", pageBookmark.Title);
// displays the title of the parent.
Console.WriteLine("Title Parent BookMark: {0}", pageBookmark.Parent.Title);
// Create new stream object
fileWrite = new System.IO.FileStream("C:\\temp\\withBookmarks2.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.Read);
// Save PDF File
doc.Save(fileWrite, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);
// Dispose the bookmark Objects
parentBookmark.Dispose();
root.Dispose();
// terminate library to free resources
acPDFCreatorLib.Terminate();
}