We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to add multiple Parents

Trying to add multiple levels such as the following any help would be great.

level 1
— Child 1 Level 1
— Child 2 Level 1
level 2
— Child 1 Level 2
— Child 2 Level 2

@cneal

Thanks for your inquiry.

As per our understandings, you want to add bullets or indented paragraphs inside PDF Page. In order to achieve that, you may please use following sample code snippet:

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Page page = doc.Pages.Add();

TextFragment headingNumber = new TextFragment("4.");
headingNumber.IsInLineParagraph = true;
headingNumber.TextState.FontSize = 10;
headingNumber.TextState.FontStyle = FontStyles.Bold;
            
TextFragment headingFragment = new TextFragment("Lorem Ipsum:");
headingFragment.Margin = new MarginInfo(10, 10, 0, 0);
headingFragment.IsInLineParagraph = true;
headingFragment.TextState.FontSize = 10;
headingFragment.TextState.FontStyle = FontStyles.Bold;

page.Paragraphs.Add(headingNumber);
page.Paragraphs.Add(headingFragment);

TextFragment numberFragment = new TextFragment("4.1.");
numberFragment.Margin = new MarginInfo(10, 0, 0, 0);
// keep this fragment with next paragraph level object
numberFragment.IsKeptWithNext = true;
TextFragment dataFragment = new TextFragment("Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum Lorem Ipsum");
// set margins to specify indenting and bullet formatting
dataFragment.Margin = new MarginInfo(30, 10, 0, 0);
dataFragment.IsInLineParagraph = true;

page.Paragraphs.Add(numberFragment);
page.Paragraphs.Add(dataFragment); 
doc.Save(dataDir + "output.pdf");

In case your requirements are different than our assumptions, please share some more details by sharing sample expected PDF document. We will test the scenario in our environment and address it accordingly.

I’m sorry for not being clear, I was referring to bookmarks.

when using this example that was not proving it is not working is the a error in the code:
sing System.IO;
using System;
using Aspose.Pdf.Facades;

namespace Aspose.Pdf.Examples.CSharp.AsposePDFFacades.TechnicalArticles
{
public class CreateNestedBookmarks
{
public static void Run()
{
// ExStart:CreateNestedBookmarks
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles();

        // New a object of Class PdfContentEditor
        PdfContentEditor editor = new PdfContentEditor();
        editor.BindPdf(dataDir + "inFile.pdf");
        // Creating child items of a chapter, in this example, the first child item also include a child item.
        Bookmark bm11 = new Bookmark();
        // Set the action type of BookMark
        bm11.Action = "GoTo";
        // Set the BookMark Destination page
        bm11.PageNumber = 3;
        // Set the BookMark title. 
        bm11.Title = "Section - 1.1.1";

        Bookmark bm1 = new Bookmark();
        bm1.Action = "GoTo";
        bm1.PageNumber = 2;
        bm1.Title = "Section - 1.1";

        Aspose.Pdf.Facades.Bookmarks bms1 = new Aspose.Pdf.Facades.Bookmarks();
        bms1.Add(bm11);
        bm1.ChildItems = bms1;

        // Creating a child item of a chapter.
        Bookmark bm2 = new Bookmark();
        bm2.Action = "GoTo";
        bm2.PageNumber = 4;
        bm2.Title = "Section - 1.2";

        // Creating a chapter (Parent Level Bookmark)
        Bookmark bm = new Bookmark();
        bm.Action = "GoTo";
        bm.PageNumber = 1;
        bm.Title = "Chapter - 1";

        Aspose.Pdf.Facades.Bookmarks bms = new Aspose.Pdf.Facades.Bookmarks();
        // Add the Section - 1.1, bookmark to bookmarks collection
        bms.Add(bm1);
        // Add the Section - 1.2, bookmark to bookmarks collection
        bms.Add(bm2);
        // Add the Bookmarks collection as child_Item of Chapter_Level bookmark
        bm.ChildItems = bms;

        // Creating a chapter (Parent Level Bookmark)
        Bookmark bm_parent2 = new Bookmark();
        bm_parent2.Action = "GoTo";
        bm_parent2.PageNumber = 5;
        bm_parent2.Title = "Chapter - 2";

        // Creating a child item of a chapter.
        Bookmark bm22 = new Bookmark();
        bm22.Action = "GoTo";
        bm22.PageNumber = 6;
        bm22.Title = "Section - 2.1";

        Aspose.Pdf.Facades.Bookmarks bms_parent2 = new Aspose.Pdf.Facades.Bookmarks();
        // Add the Section - 2.1, bookmark to bookmarks collection
        bms_parent2.Add(bm22);
        // Add the Bookmarks collection as child_Item of Chapter2_Level bookmark
        bm_parent2.ChildItems = bms_parent2;
       
        // Saves the result PDF to file
        editor.Save(dataDir + "Nested_BookMarks_out.pdf");
        // ExEnd:CreateNestedBookmarks                      
    }

@cneal

Thanks for writing back.

In order to add parent and child bookmarks, please visit following DOM article(s) in API documentation. In case you face any issue, please feel free to let us know.

Thanks! I’ve been looking at this but it does not allow me to add a page number. How would I do that

Got it. Thanks!

@cneal

Thanks for your acknowledgement.

It is good to know that you were able to achieve what you require. Please keep using our API and in case of any further query, please feel free to ask.