pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leonard Teo <leon...@ballistiq.com>
Subject ClassCastException - cannot be cast to java.lang.Number on
Date Fri, 17 May 2013 15:24:57 GMT
Hi guys,

I have a simple PDFBox application that takes a text string and inserts it
into every page of a PDF file. It is based on the AddMessageToEachPage.java
code in the example given.

I'm having an issue where I am getting a ClassCastException on
CMapParser.java:137. I can see and debug the error, but I don't know why it
would be doing this and I'm not sure what to do.

Here is the source code:
https://gist.github.com/leonardteo/3b8567e7f747ef640b70

The error is happening on line 93:

contentStream.setFont( font, fontSize );


It works on many PDF's but there are enough of these errors that it is
causing problems with our users.

Any ideas what I'm doing wrong?

Thanks,

Leo


java.lang.ClassCastException:
org.apache.fontbox.cmap.CMapParser$Operator cannot be cast to
java.lang.Number
	at org.apache.fontbox.cmap.CMapParser.parse(CMapParser.java:137)
	at org.apache.pdfbox.pdmodel.font.PDFont.parseCmap(PDFont.java:602)
	at org.apache.pdfbox.pdmodel.font.PDSimpleFont.extractToUnicodeEncoding(PDSimpleFont.java:454)
	at org.apache.pdfbox.pdmodel.font.PDSimpleFont.determineEncoding(PDSimpleFont.java:422)
	at org.apache.pdfbox.pdmodel.font.PDType1Font.determineEncoding(PDType1Font.java:269)
	at org.apache.pdfbox.pdmodel.font.PDFont.<init>(PDFont.java:194)
	at org.apache.pdfbox.pdmodel.font.PDSimpleFont.<init>(PDSimpleFont.java:84)
	at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:152)
	at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:88)
	at org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:187)
	at org.apache.pdfbox.pdmodel.PDResources.addFont(PDResources.java:518)
	at org.apache.pdfbox.pdmodel.edit.PDPageContentStream.setFont(PDPageContentStream.java:308)
	at PDFStamper.stamp(PDFStamper.java:96)
	at PDFStamper.main(PDFStamper.java:128)

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message