acBookmark.RemoveChild, acBookmark.RemoveChildEx Methods

The RemoveChild method deletes the child bookmark at the specified position.

 

Syntax

VB:

Sub RemoveChild(Index As Long)
Sub RemoveChildEx(childBookmark As acBookmark)

C#:

void RemoveChild(long Index)
void RemoveChildEx(childBookmark As acBookmark)

C++:

HRESULT RemoveChild(long Index)
HRESULT RemoveChildEx(childBookmark As acBookmark)

 

Parameters

Index

0 based index where the child bookmark to be deleted.

 

Remarks

Member of ACPDFCREACTIVEX.acBookmark.

 

Example

Sub Sample()

    ' Constants for Activation codes

    Const strLicenseTo As String = "Amyuni PDF Creator Evaluation"

    Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"

 

    ' Initializing PDFCreativeX Object

    Dim pdf As ACPDFCREACTIVEX.PDFCreactiveX = New ACPDFCREACTIVEX.PDFCreactiveX()

 

    ' Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode)

 

    ' Create Root Bookmark Object

    Dim root As ACPDFCREACTIVEX.acBookmark = pdf.RootBookmark

 

    ' Create Parent Bookmark Object

    Dim parentBookmark As ACPDFCREACTIVEX.acBookmark = New ACPDFCREACTIVEX.acBookmark()

 

    ' Insert the Parent BookMark in the Bookmark Root

    root.InsertChild(0, "Parent bookmark", "", parentBookmark)

 

    ' Create a 5 page with a text object And Page BookMark

    Dim pageCount As Integer = 5

    For i = 1 To pageCount

        ' set current page

        pdf.CurrentPage = i

 

        ' Create a Text in the current Page

        pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text" + i.ToString)

        Dim oText As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Text" + i.ToString)

        oText("Left") = 1000

        oText("Right") = 5000

        oText("Top") = 0

        oText("Bottom") = 4000

        oText("BorderColor") = &HFF00FF

        oText("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble

        oText("Text") = "Amyuni Technologies " + i.ToString

 

        ' Create the current Page Bookmark

        Dim currentPageBookmark As ACPDFCREACTIVEX.acBookmark = New ACPDFCREACTIVEX.acBookmark()

        Dim bookmarkText As String = "Bookmark to page " + i.ToString        

        ' Insert bookmark at the end

        parentBookmark.InsertChild(parentBookmark.Count, bookmarkText, oText("Name"), currentPageBookmark)

 

        ' Add page

        pdf.AddPage(i)

    Next

 

    ' Show the bookmark 1

    pdf.ReachBookmark("Bookmark to page 1")

 

    ' Save PDF

    pdf.Save("c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView)

 

    ' Opening the PDF

    pdf.Open("c:\temp\CreatePDFDocument_resulting.pdf", "")

 

    ' Getting the parentBookmark

    parentBookmark = pdf.RootBookmark.Child(0)

 

    ' Counting Bookmarks

    Console.WriteLine("Number of BookMark: {0}", parentBookmark.Count)

 

    ' Getting the first bookmark

    Dim pageBookmark As ACPDFCREACTIVEX.acBookmark

    pageBookmark = parentBookmark.Child(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)

 

    ' Save PDF

    pdf.Save("c:\temp\CreatePDFDocument_resulting2.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView)

 

End Sub

static void Sample()

{

    // Constants for Activation codes

    const string strLicenseTo = "Amyuni PDF Creator Evaluation";

    const string strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";

 

    // Initializing PDFCreativeX Object

    ACPDFCREACTIVEX.PDFCreactiveX pdf = new ACPDFCREACTIVEX.PDFCreactiveX();

 

    // Set license key

    pdf.SetLicenseKey(strLicenseTo, strActivationCode);

 

    // Create Root Bookmark Object

    ACPDFCREACTIVEX.acBookmark root = pdf.RootBookmark;

 

    // Create Parent Bookmark Object

    ACPDFCREACTIVEX.acBookmark parentBookmark;

 

    // Insert the Parent BookMark in the Bookmark Root

    root.InsertChild(0, "Parent bookmark", "", out parentBookmark);

 

    // Create a 5 page with a text object and Page BookMark

    int pageCount = 5;

    for (int i = 1; i <= pageCount; i++)

    {

        // Set the current page

        pdf.CurrentPage = i;

 

        // Create a Text in the current Page

        pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeText, "Text" + i.ToString());

        ACPDFCREACTIVEX.IacObject oText = pdf.GetObjectByName("Text" + i.ToString());

        oText["Left"] = 1000;

        oText["Right"] = 5000;

        oText["Top"] = 0;

        oText["Bottom"] = 4000;

        oText["BorderColor"] = 0xFF00FF;

        oText["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble;

        oText["Text"] = "Amyuni Technologies " + i.ToString();

 

        // Create the current Page Bookmark

        ACPDFCREACTIVEX.acBookmark currentPageBookmark;

        string bookmarkText = "Bookmark to page " + i;

        // Insert bookmark at the end

        parentBookmark.InsertChild(parentBookmark.Count, bookmarkText, (string)oText["Name"], out currentPageBookmark);

 

        // Add page

        pdf.AddPage(i);

    }

 

    // Show the bookmark 1

    pdf.ReachBookmark("Bookmark to page 1");

 

    // Save PDF

    pdf.Save(@"c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView);

 

    // Opening the PDF

    pdf.Open(@"c:\temp\CreatePDFDocument_resulting.pdf", "");

 

    // Getting the parentBookmark

    parentBookmark = pdf.RootBookmark.Child[0];

 

    // remove Child

    parentBookmark.RemoveChild(2);

 

    // Counting Bookmarks

    Console.WriteLine("Number of BookMark: {0}", parentBookmark.Count);

 

    // Getting the first bookmark

    ACPDFCREACTIVEX.acBookmark pageBookmark;

    pageBookmark = parentBookmark.Child[1];

 

    // 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);

 

    // Save PDF

    pdf.Save(@"c:\temp\CreatePDFDocument_resulting2.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView);

 

 

}

#include <iostream>

#include <sstream>

#import "c:\users\amyuni\pdfcreactivex.dll" no_namespace

 

using namespace std;

 

int main()

{

    // Constants for Activation codes

    bstr_t strLicenseTo = "Amyuni PDF Creator Evaluation";

    bstr_t strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC";

 

    // Initialize the COM subsystem

    CoInitialize(0);

 

    // IPDFCreactiveXPtr is a smart pointer type defined in pdfcreactivex.tlh,

    // the type library header file generated by the #import instruction above

    IPDFCreactiveXPtr pdf;

 

    // Create the PDFCreactiveX instance

    pdf.CreateInstance(__uuidof(PDFCreactiveX));

 

    // set license key

    pdf->SetLicenseKey(_bstr_t(strLicenseTo), _bstr_t(strActivationCode));

 

    // Create Root Bookmark Object

    IacBookmarkPtr root = pdf->RootBookmark;

 

    // Create Parent Bookmark Object

    IacBookmarkPtr parentBookmark;

 

    // Insert the Parent BookMark in the Bookmark Root

    root->InsertChild(0, "Parent bookmark", "", &parentBookmark);

 

    // Create a 5 page with a text object and Page BookMark

    int pageCount = 5;

    for (int i = 1; i <= pageCount; i++)

    {

        // Set the current page

        pdf->CurrentPage = i;

 

        // Set-up variables for attributes

        _variant_t varAttribute;

        varAttribute.vt = VT_I4;  // integers

 

        // Create a text in the current Page

        pdf->CreateObject(acObjectTypeText, "Text" + bstr_t(i));

        IacObjectPtr oText = pdf->GetObjectByName("Text" + bstr_t(i));

        oText->Attribute["Left"] = 1000;

        oText->Attribute["Right"] = 5000;

        oText->Attribute["Top"] = 0;

        oText->Attribute["Bottom"] = 4000;

        varAttribute.lVal = 0xFF00FF;

        oText->Attribute["BorderColor"] = varAttribute;

        varAttribute.lVal = acBorderWidthDouble;

        oText->Attribute["BorderWidth"] = varAttribute;

        oText->Attribute["Text"] = "Amyuni Technologies" + bstr_t(i);

 

        // Create the current Page Bookmark

        IacBookmarkPtr currentPageBookmark;

        _bstr_t bookmarkText = "Bookmark to page " + bstr_t(i);

        // Insert bookmark at the end

        parentBookmark->InsertChild(parentBookmark->Count, bookmarkText, bstr_t(oText->Attribute["Name"]), &currentPageBookmark);

 

        // Add page

        pdf->AddPage(i);

    }

 

    // Show the bookmark 1

    pdf->ReachBookmark("Bookmark to page 1");

 

    // Save PDF

    pdf->Save("c:\\temp\\CreatePDFDocument_resulting.pdf", acFileSaveView);

 

    // Opening the PDF

    pdf->Open("c:\\temp\\CreatePDFDocument_resulting.pdf", "");

 

    // Getting the parentBookmark

    parentBookmark = pdf->RootBookmark->GetChild(0);

 

    // remove Child

    parentBookmark->RemoveChild(2);

 

    // Counting Bookmarks

    cout << "Number of BookMark: " << parentBookmark->Count << endl;

 

    // Getting the first bookmark

    IacBookmarkPtr pageBookmark;

    pageBookmark = parentBookmark->GetChild(1);

 

    // Getting the title

    cout << "Title BookMark: " << pageBookmark->Title << endl;

 

    // displays the title of the parent.

    cout << "Title Parent BookMark: " << pageBookmark->Parent->Title << endl;

 

    // Save PDF

    pdf->Save("c:\\temp\\CreatePDFDocument_resulting2.pdf", acFileSaveView);

 

    // destroy objects

    pdf = NULL;

 

    return 0;

}

 

Figure: After removing the third bookmark(from the top)