Paragraph.getParagraphFormat.getStyle().getName() does not return the actual style name

Hi team,


When we call Paragraph.getParagraphFormat.getStyle().getName() the style name returned in just “Caption” instead of “Caption,Bayer Caption”.

PFA - Source word document
- Image highlighting the style details

The actual style name is (Expected output from aspose): Caption,Bayer Caption
Aspose returns : Caption

Code:
for (Paragraph custBMPara : (Iterable)doc.getChildNodes(NodeType.PARAGRAPH, true))
{
System.out.println("DefinedStylesAndLevels 3.1: " + custBMPara.getParagraphFormat().getStyle().getName());
}

Please let me know if you need any more details.

Thanks,
Satyendra

Also due to this “Caption,Bayer Caption” style, there are other issues that I am facing on some other documents as well.


For attached word document (CustomStyles1.docx), I am unable to create the TOC with custom styles from document using below string:

\o “1-9”\h\z\u\f\t"Bayer Caption,1,Bayer Section Heading,1,Caption,Bayer Caption,6,Style1Heading1,1,Style2Heading2,2,Style3Heading3,3,Style4Heading4,4,MyCustomStyle,5,UHeading1,1,UHeading2,2,UHeading3,3,UHeading4,4,"

When I call builder.insertTableOfContents(str); with above string (defining the custom styles), Aspose is not generating an TOC enteries.

If I remove Caption,Bayer Caption,6 from above string, then the TOC gets generated.
So basically, when a Style has a comma in its name, then the issue occurs.

This issue relates to:
Paragraph.getParagraphFormat.getStyle().getName() does not return the actual style name - Free Support Forum - aspose.com


Please let me know if you need more details.

Hi Satyendra,


Thanks for your inquiry. I tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-10439. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi Satyendra,


Regarding your query here, please create and attach your expected Word document here for our reference. You can create this document using Microsoft Word. We will investigate the structure of the expected (working) TOC and provide you more information.

Best regards,

Hi Hafeez,


WORDSNET-10439 - Can you please let me know the ETA to resolve this after discussing with the DEV team there?

And regarding the TOC issue:
I have already attached the document named
CustomStyles1.docx which has some custom styles.
I have attached the Expected PDF output here (ultimately, we convert the doc to pdf). I think that should suffice to proceed with your investigation.

Note that, the CustomeStyles1.docx itself does not have any TOC related to custom styles in doc, but we add the TOC field using aspose.words builder.insertTableOfContents(str);

Let me know if you need more details.

Thanks,
Satyendr

Hi Satyendr,


Thanks for your inquiry. Your issue is currently pending for analysis and is in the queue. Unfortunately, we can’t provide you any reliable estimate at the moment. We will inform you as soon as this issue is resolved. We apologize for any inconvenience.

Secondly, I am afraid, I could not see any expected.pdf attached to this thread. It would be great if you please attach both the expected.docx and expected.pdf files here for our reference.

Best regards,

I apologize for not attaching the expected PDF.
Now attached 2 PDF’s, current actual output and expected output.


Thanks,
Satyendra

Hi Satyendra,


Thanks for the additional information. But, could you please also attach expected.docx? Or, please copy and share the complete field code from the advanced field properties area (see attached screenshot) of “working TOC” with us. Please also try copying the same field code in DocumentBuilder.InsertTableOfContents method and see how it goes on your side when using Aspose.Words for .NET 14.6.0?

Best regards,

Hi Hafeez,

Issue 1:
CustomStyles1.docx - this is the source document having custom styles. What do you mean by expected.docx?


The source document it self does not have TOC.
We manually build the TOC string and insert using aspose API.

TOC String (or field code that you requested):
\o “1-9”\h\z\u\f\t"Bayer Caption,1,Bayer Section Heading,1,Caption,Bayer Caption,6,Style1Heading1,1,Style2Heading2,2,Style3Heading3,3,Style4Heading4,4,MyCustomStyle,5,UHeading1,1,UHeading2,2,UHeading3,3,UHeading4,4,"

When I call builder.insertTableOfContents(str); with above string (defining the custom styles), Aspose is not generating an TOC enteries.

If I remove Caption,Bayer Caption,6 from above string, then the TOC gets generated.
So basically, when a Style has a comma in its name, then the issue occurs.

Please let me know if you need more details.

Issue 2:
When we call Paragraph.getParagraphFormat.getStyle().getName() the style name returned in just “Caption” instead of “Caption,Bayer Caption”.

refer images attached in the first post of this thread.

The actual style name is (Expected output from aspose): Caption,Bayer Caption
Aspose returns : Caption

Thanks,
Satyendra

Hi Satyendra,


Thanks for the additional information. We are checking with these scenarios and will get back to you soon.

Best regards,

Hi Satyendra,


Thanks for being patient. Regarding WORDSNET-10439, our development team has completed the analysis of this issue and has come to a conclusion that this issue and the undesired behaviour you’re observing is actually not a bug in Aspose.Words. So, we will most likely close this issue as ‘Not a Bug’.

Microsoft Word displays a style with aliases as name plus all aliases comma separated. This means that this style is named Caption but also can be accessed by its alias through doc.Styles[“Bayer Caption”] which will return the same Style object as doc.Styles[“Caption”].

Best regards,