Free Support Forum - aspose.com

Table Of Content without pressing F9

Hi

I created a document with TOC. I am not able to view TOC without pressing F9.

Current i am using Aspose.Words.Java -Version 4.0.

Hello

Thank you for your interest in Aspose.Words for Java. Unfortunately, Aspose.Words for java does not support updating TOC at the moment. This feature is only available in .NET version of Aspose.Words.

Currently we are working on synchronizing Java and .NET versions of Aspose.Words. Once we finish this work all functionality which is supported in, NET version will be supported in Java version. I will notify you as soon as it is finished.

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

Best regards,

Hello Andrey,

Thank you for quick response.

I have another issue with TOC. Please check the below code:

I am trying to insert html content into my doc along with TOC content.

builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);

builder.writeln("Heading 1");

builder.insertHtml("Heading 1 Data...");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);

builder.writeln("Heading 1.1");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_9);

builder.insertHtml("Heading 1.1 Data...");

Actually what i am trying to create is "Heading 1" section have some data "Heading 1 Data"

After creating documet and i pressed F9 then i got follwing TOC

Heading 1.

Heading 1 Data...Heading 1.1.

Heading 1.1 Data...Heading 1.2.

Here both data and Section "Heading1 data" and "Heading 1.1" are comming on same line.

But i want to display only Headings not that data in TOC.

How to make headings sections of TOC and data differentiate. and how to avoid display section data in TOC.

Hi

Thanks for your inquiry. You can try using the following code:

// Create DocumentBuilder, which we will use to generate document.

DocumentBuilder builder = new DocumentBuilder();

// At the beggining of the document we insert TOC filed, whick will be updated before saving document.

builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u");

builder.writeln();

// Build a document with complex structure by applying different heading styles thus creating TOC entries.

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);

builder.writeln("Heading 1");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.NORMAL);

builder.writeln("Heading 1 Data");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);

builder.writeln("Heading 1.1");

builder.writeln("Heading 1.2");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);

builder.writeln("Heading 2");

builder.writeln("Heading 3");


builder.getDocument().updateFields();

// Now we can save the final document.

builder.getDocument().save("C:\\Temp\\out.doc");

Best regards,

Thank you Andrey.
In the above statement you are using builder.writeln(“Heading 1 Data”); instead of

builder.insertHtml(“Heading 1 Data…”);

I am getting html data dynamically and i am placing that data.

if my data contain html content like this builder.writeln(Heading 1 Data);

If i am using above statement then i got as it is in word document.

Heading 1

Heading 1 Data

Is there any way to insert html content under this heading section.



Hello

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

Thank you for additional information. In this case you should use the code like the following:

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);

builder.writeln("Heading 1");

builder.getParagraphFormat().clearFormatting();

builder.insertHtml("Heading 1 Data...");

if (builder.getCurrentParagraph().hasChildNodes())

builder.writeln();

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);

builder.writeln("Heading 1.1");

builder.writeln("Heading 1.2");

Please let me know in case of any issue. I will be glad to help you.

Best regards,

Thank you Andrey.
Your code helps me lot. Great.. Every thing working fine.

builder.insertHtml("Heading 1 Data...");

I tested this insertHtml with some html tags its working fine. But when i am using

Heading related tags(

,

....) those data is displayed in TOC.

This is not high priority for me... Just check this.

Hi there,

Thanks for your inquiry.

Content inserted with the

or

tags etc are given the eqivilant heading style e.g Heading 1 or Heading 2. This means this content will be inserted into the TOC. This is the correct behaviour.

Thanks,

I created a document with TOC. I am not able to view TOC without pressing F9.

Current i am using Aspose.Words.Java -Version 4.0.

As u said its available in .net. Current is it avaialbe in Java also?

Hi

Thanks for your request. This feature will be available in the next version of Aspose.Words for Java that comes out in the second half of April. We will notify you.

Best regards,

We are happy to inform you that the first auto-ported version of Aspose.Words for Java is ready. This version supports updating fields. You can get it from here.


Best regards,
Aspose.Words team


(5)

Is TOC is working in Evaluation Version<span style=“font-size: 12pt; font-family: “Times New Roman”,“serif”; color: red;”>

Hi

Thanks for your inquiry. Aspose.Words evaluation version has only two limitations: it limits the maximum number of paragraphs in the document and adds a watermark at the top of the document.

Also, if you want to test Aspose.Words without the evaluation version limitations, you can request a 30-day Temporary License. Please refer to
http://www.aspose.com/corporate/purchase/faqs/temporary-license.aspx

Best regards,

Still i didn’t get Table of Contents with out pressing F9 Button. Is this is working with temporary license?

Hi

Thanks for your request. Yes, it should work with temporary license. I cannot reproduce the problem on my side using the latest version of Aspose.Words (10.0.1) and the following code:

// Create DocumentBuilder, which we will use to generate document.

DocumentBuilder builder = new DocumentBuilder();

// At the beggining of the document we insert TOC filed, whick will be updated before saving document.

builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u");

builder.writeln();

// Build a document with complex structure by applying different heading styles thus creating TOC entries.

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);

builder.writeln("Heading 1");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.NORMAL);

builder.writeln("Heading 1 Data");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);

builder.writeln("Heading 1.1");

builder.writeln("Heading 1.2");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);

builder.writeln("Heading 2");

builder.writeln("Heading 3");

// Opdate fields in the document to update TOC.

builder.getDocument().updateFields();

// Now we can save the final document.

builder.getDocument().save("C:\\Temp\\out.doc"

Please try using this code and the latest version of Aspose.Words and let me know how it goes on your side.

If it does not help, could you please attach you document and code which will allow me to reproduce the problem on my side.

Best regards,