We are having a TextFragment with two segments. First one having a plain segment and the second one having a subscript or superscript. When we generate the PDf, we observed that the second segment is not following subscript/superscript even after we set that as true. What is the issue here?
It seems you are experiencing issues with the subscript and superscript formatting in a TextFragment
when generating a PDF. This can occur due to various reasons, including the version of the Aspose.PDF library you are using.
In a previous discussion, a user reported similar issues where the TextState
settings for subscript and superscript were not retained when creating repeating header rows in a table. This led to the creation of a ticket for further investigation by the Aspose team. The issue was later addressed in a subsequent release of the library, which suggests that updating to the latest version may resolve your problem.
To ensure that your subscript and superscript settings are applied correctly, you can use the following code snippet as a reference:
Document document = new Document();
Page page = document.getPages().add();
TextFragment plainText = new TextFragment("Normal Text ");
TextFragment subscriptText = new TextFragment("Subscript");
subscriptText.getTextState().setSubscript(true);
TextFragment superscriptText = new TextFragment("Superscript");
superscriptText.getTextState().setSuperscript(true);
page.getParagraphs().add(plainText);
page.getParagraphs().add(subscriptText);
page.getParagraphs().add(superscriptText);
document.save("Output.pdf");
Make sure you are using a version of the Aspose.PDF library that includes the fixes for these issues. If you are still facing problems after updating, consider checking the documentation or reaching out to the support team for further assistance.
If you need more detailed guidance or have specific code that you would like to troubleshoot, feel free to share it!
Sources:
[1]: Extract SuperScripts and SubScripts text from PDF - Aspose Documentation