I am using spire.doc.free::3.9.0 in java.
I need to replace the font of the text in the table with one downloaded from the Internet.
This works locally, but not through the docker project image.
Can you help me with this?
- Code: Select all
var urlPath = Thread.currentThread().getContextClassLoader().getResource("fonts");
var document = new com.spire.doc.Document(new ByteArrayInputStream(stream.toByteArray()));
var fontPath = new PrivateFontPath();
fontPath.setFontName("capture");
fontPath.setFontPath(urlPath.getPath() + "/capture-it.ttf");
document.setEmbedFontsInFile(true);
document.setEmbedSystemFonts(false);
document.getPrivateFontList().add(fontPath);
for (var objSection : document.getSections()) {
if (objSection instanceof com.spire.doc.Section section) {
for (var objTable : section.getTables()) {
if (objTable instanceof Table table1) {
for (var objRow : table1.getChildObjects()) {
if (objRow instanceof TableRow row) {
for (var objCell : row.getCells()) {
if (objCell instanceof TableCell cell) {
for (var objParagraph : cell.getParagraphs()) {
if (objParagraph instanceof com.spire.doc.documents.Paragraph pr) {
for (var objText : pr.getChildObjects()) {
if (objText instanceof TextRange text) {
text.getCharacterFormat().setFontName("capture");
}
}
}
}
}
}
}
}
}
}
}
}