Since Aspose.Pdf for Java 20.7 (all versions since), individual style in TextSegment elements seems to be completely ignored; instead the style for the TextFragment seems to override individual settings.
The following code reproduces the issue. Below the code, the example of how it was correct until 20.6, and the issue since 20.7
import com.aspose.pdf.*;
public class TestClass {
private static final String ABSOLUTE_FILEPATH = "boldtext-test.pdf";
public static void main(String[] args) throws Exception {
Document document = new Document();
Page page = document.getPages().insert(1);
TextFragment txt = new TextFragment(new TabStops());
txt.getTextState().getTabStops().add(100);
TextSegment bold = new TextSegment("This MUST be bold");
bold.getTextState().setFontStyle(FontStyles.Bold);
txt.getSegments().add(bold);
txt.getSegments().add(new TextSegment("#$TAB"));
txt.getSegments().add(new TextSegment("This is regular"));
page.getParagraphs().add(txt);
document.save(ABSOLUTE_FILEPATH);
}
}
20.6: aspose-20.6.png (19.0 KB)
20.7: aspose-20.7.png (18.6 KB)