[ https://issues.apache.org/jira/browse/PDFBOX-1663?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Lehmkühler updated PDFBOX-1663: --------------------------------------- Comment: was deleted (was: Thank you for your e-mail. Unfortunately I am away from the office. I will be back Tuesday 13th August 2013. If you require support please e-mail ambit.pb.supp...@sungard.com. Thank you. ) > Hello World using a TrueType font ArrayIndexOutOfBoundsException > ---------------------------------------------------------------- > > Key: PDFBOX-1663 > URL: https://issues.apache.org/jira/browse/PDFBOX-1663 > Project: PDFBox > Issue Type: Bug > Affects Versions: 1.8.2 > Environment: Windows 7 SP1 32-bit, pdfbox 1.8.2., NetBeans IDE 6.9.1 > Reporter: Duncan Horrocks > Assignee: Andreas Lehmkühler > Fix For: 2.0.0 > > > The small example “Hello World using a TrueType font” on the pdfbox website > does not work when selecting the Windows font “cour.ttf” (Courier New). It > works with the non-fixed width fonts that I have tried (Arial, Albertus, > Bookman Old Style, Garamond, Palatino, Segoe UI) and it works with Lucida > Console, a fixed width font, but not Courier New. > This is the error: > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5 > at > org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadDescriptorDictionary(PDTrueTypeFont.java:418) > 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 pdfbox_ttf_test.Main.main(Main.java:31) > To me this is the same error as PDFBOX-1335, except maybe it is still not > fixed for all fonts. > I am using Windows 7 SP1 32-bit, pdfbox 1.8.2., NetBeans IDE 6.9.1 > This is my source: > ----------------------- <snip> ------------------------- > /* > * To change this template, choose Tools | Templates > * and open the template in the editor. > */ > package pdfbox_ttf_test; > import org.apache.pdfbox.pdmodel.PDDocument; > import org.apache.pdfbox.pdmodel.PDPage; > import org.apache.pdfbox.pdmodel.font.PDFont; > import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont; > import org.apache.pdfbox.pdmodel.edit.PDPageContentStream; > import org.apache.pdfbox.exceptions.COSVisitorException; > import java.io.IOException; > /** > * > * @author Duncan > */ > public class Main { > /** > * @param args the command line arguments > */ > public static void main(String[] args) throws IOException, > COSVisitorException { > // TODO code application logic here > PDDocument document = new PDDocument(); > PDPage page = new PDPage(); > document.addPage( page ); > // Create a new font object by loading a TrueType font into the > document > PDFont font = PDTrueTypeFont.loadTTF(document, > "C:\\Windows\\Fonts\\cour.ttf"); > // Start a new content stream which will "hold" the to be created > content > PDPageContentStream contentStream = new PDPageContentStream(document, > page); > // Define a text content stream using the selected font, moving the > cursor and drawing the text "Hello World" > contentStream.beginText(); > contentStream.setFont( font, 12 ); > contentStream.moveTextPositionByAmount( 100, 700 ); > contentStream.drawString( "Hello World" ); > contentStream.endText(); > // Make sure that the content stream is closed: > contentStream.close(); > // Save the results and ensure that the document is properly closed: > document.save( "Hello World.pdf"); > document.close(); > } > } > -------------------------- <end snip> ----------------------------- -- 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