I use spire.doc for JAVA to generate PDF documents from Word documents.
In Word document template is Calibri font used as default. But in the generated PDF I want to use CARLITO instead of CALIBRI font in all document without the need to apply new font to all document paragraphs, tables, list format styles.
So I am trying to tell spire.doc to use CARLITO as CALIBRI font, so adding font CARLITO font with fake CALIBRI font name.
I am using this code:
- Code: Select all
ToPdfParameterList params = new ToPdfParameterList();
List<PrivateFontPath> fonts = new ArrayList<>();
// here is the fake calibri font name used with carlito font path
fonts.add(new PrivateFontPath("Calibri", carlitoPath));
params.setPrivateFontPaths(fonts);
document.saveToStream(fileStream, params);
Currently it doesn't work, the default TimesNewRoman font is used when PDF is generated. Is it possible to achieve the described use case? Is there any other simple way how to achieve it?
Thank you for your help