Juan Carlos Castilla created PDFBOX-1559: --------------------------------------------
Summary: Error when using monospaced Fonts Key: PDFBOX-1559 URL: https://issues.apache.org/jira/browse/PDFBOX-1559 Project: PDFBox Issue Type: Bug Affects Versions: 1.8.0 Environment: Windows XP, Helios Eclipse Reporter: Juan Carlos Castilla I'm trying to load some Ubuntu fonts in a PDF but I'm having problems with monospaced ones. An small example: -------------------------------------------------------------------------------------------- public class PDFTest { public static void main (String [] args) throws IOException { PDDocument document = null; try { document = new PDDocument (); PDPage page = new PDPage (); document.addPage (page); PDFont font = PDTrueTypeFont.loadTTF (document, "D:\\UbuntuMono-R.ttf"); PDPageContentStream contentStream = new PDPageContentStream ( document, page); contentStream.beginText (); contentStream.setFont (font, 12); contentStream.moveTextPositionByAmount (100, 700); contentStream.drawString ("Hello World"); contentStream.endText (); contentStream.close (); document.save ("d:\\Hello World.pdf"); document.close (); } catch (Exception e) { e.printStackTrace (); } } } -------------------------------------------------------------------------------------------- Output: -------------------------------------------------------------------------------------------- java.lang.ArrayIndexOutOfBoundsException: 5 at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:409) at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:201) at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:177) at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:158) at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:145) at org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(PDTrueTypeFont.java:132) at es.datisa.informes.test.PDF.PDFTest.main(PDFTest.java:21) -------------------------------------------------------------------------------------------- Trying with other monospaced (like DejaVuSansMono.ttf from windows fonts) shows the same error. If I try with another Ubuntu Font (not mono) everything is ok. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira