Free Support Forum - aspose.com

Create a linked index

Hi,

with aspose.pdf, is it possible to do the following?

create a linked index of all products with the corresponding Page-nr that product is on, at the top of the document:

ie

Page 1:
index:
product 1 (link to that page) … Page 2
product 2 … Page 2
product 3 … Page 3

Page 2:


regards, Tilli

Dear customer,

Thanks for your consideration.

The function you want is supported in Aspose. Pdf, but I have found a bug when I test the example. Please download the hotfix here.

Here is an example:

[c#]
Pdf pdf = new Pdf();

Section section = new Section(pdf);
pdf.Sections.Add(section);

Text text1 = new Text(section);
section.Paragraphs.Add(text1);

Segment segment1 = new Segment(text1);
text1.Segments.Add(segment1);
segment1.Content = “product 1”;
segment1.TextInfo.IsUnderline = true;
segment1.Hyperlink.LinkType = HyperlinkType.Local;
segment1.Hyperlink.TargetID = “product1”;

Text text2 = new Text(section);
section.Paragraphs.Add(text2);

Segment segment2 = new Segment(text2);
text2.Segments.Add(segment2);
segment2.Content = “product 2”;
segment2.TextInfo.IsUnderline = true;
segment2.Hyperlink.LinkType = HyperlinkType.Local;
segment2.Hyperlink.TargetID = “product2”;

Text text3 = new Text(section);
section.Paragraphs.Add(text3);
text3.IsFirstParagraph = true;
text3.ID = “product1”;

Segment segment3 = new Segment(text3);
text3.Segments.Add(segment3);
segment3.Content = “product 1 info …”;

Text text4 = new Text(section);
section.Paragraphs.Add(text4);
text4.IsFirstParagraph = true;
text4.ID = “product2”;

Segment segment4 = new Segment(text4);
text4.Segments.Add(segment4);
segment4.Content = “product 2 info …”;

pdf.Save(…);

[VisualBasic]
Dim pdf As Pdf = New Pdf()

Dim section As Section = New Section(pdf)
pdf.Sections.Add(section)

Dim text1 As Text = New Text(section)
section.Paragraphs.Add(text1)

Dim segment1 As Segment = New Segment(text1)
text1.Segments.Add(segment1)
segment1.Content = “product 1”
segment1.TextInfo.IsUnderline = True
segment1.Hyperlink.LinkType = HyperlinkType.Local
segment1.Hyperlink.TargetID = “product1”

Dim text2 As Text = New Text(section)
section.Paragraphs.Add(text2)

Dim segment2 As Segment = New Segment(text2)
text2.Segments.Add(segment2)
segment2.Content = “product 2”
segment2.TextInfo.IsUnderline = True
segment2.Hyperlink.LinkType = HyperlinkType.Local
segment2.Hyperlink.TargetID = “product2”

Dim text3 As Text = New Text(section)
section.Paragraphs.Add(text3)
text3.IsFirstParagraph = True
text3.ID = “product1”

Dim segment3 As Segment = New Segment(text3)
text3.Segments.Add(segment3)
segment3.Content = “product 1 info …”

Dim text4 As Text = New Text(section)
section.Paragraphs.Add(text4)
text4.IsFirstParagraph = True
text4.ID = “product2”

Dim segment4 As Segment = New Segment(text4)
text4.Segments.Add(segment4)
segment4.Content = “product 2 info …”

pdf.Save(…)


[XML]
<?xml version="1.0" encoding="utf-8" ?>




product 1




product 2




product 1 info …




product 2 info …