Issue with table of content


#1

Hi,

I have requirement to set html string as “HEADING 1” in word and the same heading should come in TOC.

below is the code snippet:

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
builder.getParagraphFormat().setSpaceAfterAuto(true);
builder.insertHtml(“Heading title       


kndldmldm,led

,mkldcmdmlkm
”);

Above is able to convert the html to proper text format but at the time of TOC , its not updating the Title.

TOC code:
builder.insertTableOfContents( “\o “1-3” \h \z \u”);
document.updateFields();

Any help would be much appreciated.

Thank you…


Extract Paragraphs under different headings from word Document
#2

@Pintutrnt

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document if you are using any.
  • Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


#3

Hello Tahir,

I am attaching the input document and sample working source code. and have mentioned the comment in the source code about expected behaviour.

And one more quick update i need on ticket WORDSNET-18984 if possible from your end.SampleCode.zip (1.7 KB)
input_temp.zip (12.5 KB)

Thank you…


#4

@Pintutrnt

We have tested the scenario using the latest version of Aspose.Words for Java 19.8 and have not found the shared issue. So, please use Aspose.Words for Java 19.8. We have attached the output document with this post for your kind reference. 19.8.zip (11.1 KB)

Currently, there is no update available on this issue. We will inform you once there is an update available on it. Thanks for your patience.


#5

@tahir.manzoor

Thank you. It worked after upgrading to mentioned version for some cases.

When i am passing a simple string without any html tags or character then it’s getting updated in title but its not getting updated in TOC. Can you please help here.

Thank you…


#6

And one more query , can we make useBuilderFormatting value to be TRUE(i want to retain the font color, size etc)

builder.insertHtml(htmlString, TRUE)


#7

@Pintutrnt

Please share the documents and code example for which you are facing this issue. We will investigate the issue and provide you more information on it.

When useBuilderFormatting is false, DocumentBuilder formating is ignored and formatting of inserted text is based on default HTML formatting. As a result, the text looks as it is rendered in browsers.

When useBuilderFormatting is true, formatting of inserted text is based on DocumentBuilder formatting, and the text looks as if it were inserted with Write.


#8

@tahir.manzoor,

I have uploaded the sample code. you can use the previous docx file as input.

Thank you…SampleCode.zip (1.8 KB)


#9

@Pintutrnt

Perhaps, you are using old version of Aspose.Words for Java. Please use the latest version of Aspose.Words for Java 19.8.We have not found the shared issue at our end.

Could you please share your problematic output and expected output documents here for further testing? We will then provide you more information about your query.


#10

Hi,

I have table(s) in html string.when i am inserting this html table(s) on word docs using aspose word java ,it not fitting in the word doc/docx page , some parts of the generated table is getting cut.

I have attached the sample code and input template as well.

Can you please help me on the same.

Thank you…SampleCode.zip (2.3 KB)
input_temp.zip (12.5 KB)


#11

@Pintutrnt

Please use Table.autoFit method as shown below to get the desired output.

for(Table table : document.getFirstSection().getBody().getTables())
    table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW);
document.save("D:\\output_temp.docx", SaveFormat.DOCX);

#12

Thank you tahir… it worked.

One more query related to PDF file saving using Aspose word java. When i am passing “₹” as part of generation as PDF its coming as rectangular bracket in Linux OS but perfectly fine in windows 10.

My query is - how can we put that particular True font type in Application WAR so that at run time if above mentioned symbol doesn’t find in OS’s TRUE FONT. it should take it from Application WAR file.
[I don’t want it to install any true font type in any platform if its not available].

Thank you…


#13

@Pintutrnt

Aspose.Words provides the IWarningCallback which can be implemented to receive warnings of potential fidelity loss when loading or saving a document.Please refer to the following article.

How to Receive Notification of Missing Fonts and Font Substitution during Rendering


#14

Hi Team,

can we give different font setting for same HEADING style at different places in same document. For example i am adding “HEADING_1” style in start of the document then i am moving the builder using
builder.moveToDocumentEnd(); method again i am trying to set the same HEADING_1 style with different font size. After final save of the same document ,all the HEADING_1 style paragraphs are coming in different font size that i have set it after moving builder.


#15

@Pintutrnt

Yes, you can apply direct formatting to the text using DocumentBuilder.Font property or Run.Font property.

Please note that formatting is applied on a few different levels. For example, let’s consider formatting of simple text. Text in documents is represented by Run element and a Run can only be a child of a Paragraph. You can apply formatting

  1. to Run nodes by using Character Styles e.g. a Glyph Style .
  2. to the parent of those Run nodes i.e. a Paragraph node ( possibly via paragraph Styles ).
  3. you can also apply direct formatting to Run nodes by using Run attributes ( Font ). In this case the Run will inherit formatting of Paragraph Style, a Glyph Style and then direct formatting.

#16

Hi Team,

Boundary of Header row in a table is coming thicker in PDF format but in word its coming as expected(means - header row is not coming thicker). I am attaching the input ,output file as well as sample code. Please help me ASAP.

Thank you…input_temp.zip (12.7 KB)
SampleCode.zip (1.9 KB)
output_temp.zip (80.3 KB)


#17

Please do not use Table.setBorders in your code. You can remove following line of code to get the desired output.

table.setBorders(LineStyle.SINGLE, 1.0, Color.BLACK);

The border in Word document is also thicker. You can check this output by zooming it in Word document or convert Word document to PDF using MS Word.


#18

Thank you tahir…


#19

Hi Tahir,

Sometimes i am getting below exception :
Caused by: java.lang.IllegalStateException: Inaccessible because font is defined by theme font.
at com.aspose.words.zzWY.getName(Unknown Source)
at com.aspose.words.zzYYA.getNameOther(Unknown Source)
at com.aspose.words.Inline.zzZiy(Unknown Source)
at com.aspose.words.zz6T.zzY(Unknown Source)
at com.aspose.words.zz7Q.visitRun(Unknown Source)
at com.aspose.words.Run.accept(Unknown Source)
at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Paragraph.accept(Unknown Source)
at com.aspose.words.CompositeNode.acceptChildren(Unknown Source)
at com.aspose.words.CompositeNode.acceptCore(Unknown Source)
at com.aspose.words.Body.accept(Unknown Source)
at com.aspose.words.zz7Q.zzV(Unknown Source)
at com.aspose.words.zz7R.zzZEG(Unknown Source)
at com.aspose.words.zz7R.zzZEH(Unknown Source)
at com.aspose.words.zz7Q.zzMw(Unknown Source)
at com.aspose.words.zz6F.zzZEG(Unknown Source)
at com.aspose.words.zz6F.zzZ(Unknown Source)
at com.aspose.words.zzZF1.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.zzZ(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
at com.aspose.words.Document.save(Unknown Source)
I am using Aspose word java 19.2 on windows 10 platform.

Thank you…


#20

@Pintutrnt

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.