Free Support Forum - aspose.com

IsAutoSequence limited to 3 level?

I turned around an "index out of range" error while generating a pdf from a xml for a couple of day.

the number of level seem to be limited to 3 ?? Generating a TOC for a document fails when more than

3 chapter level exist: 1. 1.1. 1.1.1 and 1.1.1.1

Is there a hidden parameter somewhere you could change? I need to generate document with one main chapter and up to 8 sub chapters !?

1. main (level1)

1.1 sub (level2)

1.2. sub (level2)

1.2.1 sub (level3)

1.2.1.1 sub (level4)

1.2.1.1.1 etc.

Hi,


Well, I checked your scenario with the Aspose.Pdf for .NET v6.7 and there is no restriction on levels of TOC. Following is the sample code I used to add up to 5 levels in a TOC.


//Create a section in the Pdf document

Aspose.Pdf.Generator.Pdf pdf1 = new Pdf();

Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

for (int Level = 1; Level != 6; Level++)

{

Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, Level);

Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);

heading2.Segments.Add(segment2);

heading2.IsAutoSequence = true;

segment2.Content = "this is heading of level ";

segment2.Content += Level.ToString();

//Add the heading into Table Of Contents.

heading2.IsInList = true;

sec1.Paragraphs.Add(heading2);

}

pdf1.Save("E:\\AP Data\\March2012\\TOC.Pdf");


Please share your sample code and template file (if any) to show us the issue. We will check it and get back to you soon.

Sorry for the inconvenience,

Hi Nausherwan,

your code works, I can confirm this. The problem appear when a toc is added.

Here is the snippet:

Aspose.Pdf.Generator.Pdf pdf1 = new Pdf();

pdf1.BookmarkLevel = 6;

ListSection TOCSection1 = new ListSection(pdf1);

TOCSection.ListType = ListType.TableOfContents;

Text SText1 = new Text("Table Of Content1");

TOCSection1.Title = SText1;

TOCSection1.Title.TextInfo.Alignment = AlignmentType.Center;

TOCSection1.Title.TextInfo.FontSize = 20;

pdf1.Sections.Add(TOCSection1); //without this line all everything is ok ...

Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

//error ifmax >4!!!!

int max=5;

for (int Level = 1; Level != max; Level++) {

Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf1, sec1, Level); Aspose.Pdf.Generator.Segment segment2 = new Aspose.Pdf.Generator.Segment(heading2);

heading2.Segments.Add(segment2);

heading2.IsAutoSequence = true;

segment2.Content = "this is heading of level ";

segment2.Content += Level.ToString();

//Add the heading into Table Of Contents.

heading2.IsInList = true; sec1.Paragraphs.Add(heading2);

}

pdf1.Save(Server.MapPath("~//temp//") + "TOC.Pdf");

Any idea ?

Best regards

Kagel

Hi Kagel,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for your feedback and sample code.

I am able to reproduce your mentioned issue using your sample code. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-33373. You will be notified via this forum thread regarding any update against your issue.

Sorry for the inconvenience,

yesterday we updated our aspose for pdf from V 6.7 to 7.4
the creation of TOC for pdf having chapters with more than 3 level is still not resolved
here is the code:

_pdf = new Pdf();
_pdf.IsBookmarked = true;
_pdf.BookmarkLevel = 10;
ListSection TOCSection = new ListSection(_pdf);
TOCSection.ListType = ListType.TableOfContents;
_pdf.Sections.Add(TOCSection);

if we omit the toc creation reduce the level to less than 3 everything is
fine, otherwise we get still the “index of of range error” on saving the generated pdf

any idea?


Hi Pascal,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for a delay in response.

I am afraid the issue is not resolved yet regarding creation of TOC in a PDF file. I have asked the development team to share an ETA regarding the resolution of the issue. As soon as I get a feedback, I will update you via this forum thread.

Sorry for the inconvenience,

Hi Nausherwan,

just check out the follwing snipped:

public void CreateTestTOC()
{
_pdf = new Pdf();
_pdf.IsBookmarked = true; // im viewer inhaltsverzeichnis mit hyperlink anzeigen
_pdf.BookmarkLevel = 10; //anzahl ebenen die bei den BookmarkLevel angezeigt werden

ListSection TOCSection = new ListSection(_pdf);
TOCSection.ListType = ListType.TableOfContents;

Text SText = new Text(“Table Of Content”);

TOCSection.Title = SText;
TOCSection.Title.TextInfo.Alignment = AlignmentType.Center;
TOCSection.Title.TextInfo.FontSize = 20;

//test
_pdf.Sections.Add(TOCSection);

_section = _pdf.Sections.Add();

CreateChapter(“level1”, 1);
CreateChapter(“level2”, 2);
CreateChapter(“level1”, 1);
CreateChapter(“level2”, 2);
CreateChapter(“level2”, 2);
CreateChapter(“level3”, 3);
// CreateChapter(“level4”, 4); //index out of range

CreateParagraph(“ein eintrag”);

_pdf.Save(“TOC.pdf”);

System.Diagnostics.Process.Start(“TOC.pdf”);
}

As soon as you uncomment the line CreateChapter(“level4”, 4);
the index out of range error should appear, at least on my PC

Best regards
Pascal Hoffmann

Hi Pascal,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

This is the same issue as PDFNEWNET-33373 which is already registered in our issue tracking system. As I mentioned in my last reply, we will update you regarding the ETA once we get a feedback from the development team. Please be patient and spare us some time.

Sorry for the inconvenience,

Hi Nausherwan,

are there intermediate news about the correction state regarding this bug?

Or is it actually known in which patch it will be available ?

Best regards

Kagel

Hi Kagel,


Thanks for your patience.

The development team has been busy resolving some other priority issues and I am afraid this problem is not yet fixed. Nevertheless I have requested the development team to share the possible ETA for its resolution. As soon as I have some updates, I will let you know. We are sorry for this delay and inconvenience.

Hi Kagel,


Thanks for your patience.

I am pleased to share that the issue reported earlier has
been resolved and its resolution will be included in upcoming release version of Aspose.Pdf for .NET 7.7.0 (which is planned to release in current month). Please, please feel free to contact. Please be patient and wait for the new release version and
as soon as it becomes available, we would be more than happy to update you with
the status of availability.

Your patience and comprehension is greatly appreciated in
this regard.

<o:p></o:p>

The issues you have found earlier (filed as PDFNEWNET-33373) have been fixed in Aspose.Pdf for .NET 7.7.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.