I am trying to load .woff and .woff2 fonts and getting below exception. Help me to resolve this.
Note: I can't attach the font file since not having permission to share.
public void pdfExport() {
try {
PDFont font = PDType1Font.TIMES_ROMAN;
PDDocument document = new PDDocument();
File file = new File("C:\\Users\\Desktop\\font_test\\font.woff");
String path = file.getAbsolutePath();
if (!StringUtils.isBlank(path)) {
font = PDType0Font.load(document, file);
}
} catch (IOException e) {
e.printStackTrace();
}
}
An exception is below.
java.io.IOException: head is mandatory at org.apache.fontbox.ttf.TTFParser.parseTables(TTFParser.java:181) at org.apache.fontbox.ttf.TTFParser.parse(TTFParser.java:150) at org.apache.fontbox.ttf.TTFParser.parse(TTFParser.java:106) at org.apache.pdfbox.pdmodel.font.PDType0Font.load(PDType0Font.java:78)