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

Free Support Forum - aspose.com

Behavior different from updating the TOC between Windows 7 and Windows server 2008

Hello,

I have a problem when I try to update the TOC of a doc file (using “UpdateFields()”). Windows 7, the TOC is updated correctly but not on Windows Server 2008 R2. I have Aspose 14.3 on both machines.

On Windows 7 (with Office 2010):

INTRODUCTION 2
1. General 2
2. Presentation 2
2.1. data 2
2.2. definition 2


On Windows Server 2008 R2 (without Office 2010):
INTRODUCTION 2


The TOC use some custom styles: { TOC \o “1-3” \h \z \t “ELA-Title;4;Intro_Title1;2;Intro_Title2;3;Intro_Title3;4” }

See original file in the attachements.

Thanks for your help.
                                <br><br>

Hi Fabrice,


Thanks for your inquiry. Aspose.Words does not require Microsoft Word to be installed in order to run or function properly. It is an independent API. It should work in similar manner with or without Microsoft Office installed. Upon re-calculating TOC in your attached “UpdateTOC.docx” document, even Microsoft Word 2013 running on Windows 7 machine shows a single entry i.e. “INTRODUCTION 2”. This seems to be an expected behavior. If we can help you with anything else, please feel free to ask.

Best regards,

But when I update the TOC with Microsoft Office 2010 (on Windows 7), all titles are displayed.

EDIT: I made other tests and I saw that I had this “problem” on machines with Windows in English and I had all levels on a machine with Windows in French. There may be a link

Hi Fabrice,


Thanks for your inquiry. Setting English language for Windows 7 and French as an editing language for Microsoft Word unfortunately didn’t help us to reproduce this issue on our end. It would be great if you please list all steps to reproduce this issue here for our reference. This will definitely help us to get to the bottom of this problem.

Best regards,

I understood why I had this behavior. The TOC was created with the
regional options set to french, and the list separator is “;” so the TOC
is:
{ TOC \o “1-3” \h \z \t “ELA-Title;4;Intro_Title1;2;Intro_Title2;3;Intro_Title3;4” }

But in english, the list separator is “,”, and the TOC must be:
<span style=“font-size:10.0pt;font-family:“Courier New”” lang=“EN-GB”>
{ TOC \o “1-3” \h \z \t “ELA-Title,4,Intro_Title1,2;Intro_Title2,3,Intro_Title3,4” } <span style=“font-size:12.0pt;font-family:“Times New Roman”,“serif”;mso-fareast-language:FR”>

As I update the TOC with regional options in english, I have to replace “;” by “,” in the TOC before updating:



<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>FR</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-fareast-language:EN-US;}

<![endif]–>

Aspose.Words.NodeCollection fieldStarts = doc.GetChildNodes(Aspose.Words.NodeType.FieldStart, true);

foreach (Aspose.Words.Fields.FieldStart fieldStart in fieldStarts)

{

if (fieldStart.FieldType == Aspose.Words.Fields.FieldType.FieldTOC)

{

Aspose.Words.Node fieldSeparator = fieldStart.NextSibling;

fieldSeparator.Range.Replace(";", System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.ListSeparator, false, false);

}

}

Hi Fabrice,


Thanks for the details. It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

Best regards,