You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Aylward (JIRA)" <ji...@apache.org> on 2016/03/09 19:26:40 UTC
[jira] [Resolved] (PDFBOX-3260) IOException "head is mandatory"
when importing a TTF file
[ https://issues.apache.org/jira/browse/PDFBOX-3260?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Aylward resolved PDFBOX-3260.
----------------------------------
Resolution: Not A Problem
I can't seem to reproduce it in test cases outside of Tomcat either. It is likely some kind of configuration issue on my end. For reference, here is the test case I used to match the resource load that is happening in tomcat:
The actual resource in my configuration is in a JAR on the tomcat classpath, so I tried replicating that here.
{code:title=Test.java|borderStyle=solid}
@Test
public void testFontFromJar() throws IOException {
final URL jar = this.getClass().getResource("/micrFontInJar.jar");
assert jar != null : "Unable to locate TTF Jar in classpath";
URL ttfURL = new URL("jar:" + jar.toString() + "!/MICREncoding.ttf");
try (PDDocument pdf = new PDDocument();//
final InputStream fontStream = ttfURL.openStream()) {
assert fontStream != null : "Unable to locate font resource";
final PDType0Font micrFont = PDType0Font.load(pdf, fontStream);
assert micrFont != null : "Unable to load MICR font";
}
ttfURL = new URL("jar:" + jar.toString() + "!/micrenc.ttf");
try (PDDocument pdf = new PDDocument();//
final InputStream fontStream = ttfURL.openStream()) {
assert fontStream != null : "Unable to locate font resource";
final PDType0Font micrFont = PDType0Font.load(pdf, fontStream);
assert micrFont != null : "Unable to load MICR font";
}
}
{code}
The tests pass for both fonts in the JAR, so I'll inspect my tomcat configuration/environment to see what could be causing the issue. Maybe I accidentally have 2 of the same files on the classpath and it's grabbing the wrong one or some other odd problem.
Thanks for the help.
> IOException "head is mandatory" when importing a TTF file
> ---------------------------------------------------------
>
> Key: PDFBOX-3260
> URL: https://issues.apache.org/jira/browse/PDFBOX-3260
> Project: PDFBox
> Issue Type: Bug
> Components: FontBox
> Affects Versions: 1.8.11, 2.0.0
> Environment: Linux, Oracle Java8
> Reporter: John Aylward
> Attachments: micrenc.ttf
>
>
> I'm trying to import this font (http://www.1001fonts.com/micr-encoding-font.html#character-map) but I get the following exception:
> {quote}
> 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)
> {quote}
> A similar issue happens with 1.8.11 as well.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org