Flying-saucer-pdf table 'name' does not exist in exception on ubuntu
I have a simple spring web application where I create a downloadable pdf with flying-saucer-pdf from html which I render with thymelean. It works well and generates html string correctly. I am developing on windows and during development, generating pdf also works well, but on ubuntu server does not work.
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont(fontFile, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
fontFile exists, on ubuntu too, it is programmatically accessible and can access it, but when I want to pdf I got the following exception. I have no ideal of what it really means.
Caused by: com.lowagie.text.DocumentException: Table name does not exist in / opt / RFIT / TextileApp / conf / font / Rubik -Regular.ttf at com.lowagie.text.pdf.TrueTypeFont.getBaseFont (Unknown source) ~ [itext -2.1.7.jar: na] at com.lowagie.text.pdf.TrueTypeFont.process (Unknown source) ~ [itext-2.1.7.jar: na] at com.lowagie.text.pdf.TrueTypeFontUnicode. (Unknown source) ~ [itext-2.1.7.jar: na] at com.lowagie.text.pdf.BaseFont.createFont (Unknown source) ~ [itext-2.1.7.jar: na] at com.lowagie.text .pdf.BaseFont.createFont (Unknown source) ~ [itext-2.1.7.jar: na] at com.lowagie.text.pdf.BaseFont.createFont (Unknown source) ~ [itext-2.1.7.jar: na] at org.xhtmlrenderer.pdf.ITextFontResolver.addFont (ITextFontResolver.java:201) ~ [Flight-saucers-PDF-9.1.6.jar: on] at org.xhtmlrenderer.pdf.ITextFontResolver.addFont (ITextFontResolver.java:193) ~ [FlightSaucer-PDF-9.1.6.jar: on] at org.xhtmlrenderer.pdf.ITextFontResolver.addFont (ITextFontRes18:18 -saucer-pdf-9.1.6.jar: at] at hu.rfit.textile.service.impl.PdfPrinterService.printPDF (PdfPrinterService.java:53) ~ [TextileApp-1.0.0-SNAPSHOT.jar: 1.0.0- SNAPSHOT: 4749]
on some forum they said that I should add the font to / usr / share / fonts dirt and re-create the font cache. But it doesn't work.
source to share
I had the same problem adding a font using fly-saucher. The root cause of the problem is the truncated font file. This issue can lead to your operating system or maven filtering. In my example I was using maven and the following steps solve the problem.
If you are using maven you must add the font file to your resources folder.
For example,
Src / main / resources / fonts / samplefont.ttf
After that, you should define resources in the pom.xml like this:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>font/*</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>font/*</include>
</includes>
</resource>
</resources>
After that, you can use the following definition,
ITextRenderer renderer = new ITextRenderer();
renderer.getFontResolver().addFont("/font/samplefont.ttf",
BaseFont.IDENTITY_H,
BaseFont.EMBEDDED);
I hope this is helpful.
source to share