Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5DD11DC6B for ; Mon, 20 May 2013 08:02:22 +0000 (UTC) Received: (qmail 62083 invoked by uid 500); 20 May 2013 08:02:22 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 62004 invoked by uid 500); 20 May 2013 08:02:20 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 61952 invoked by uid 99); 20 May 2013 08:02:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 May 2013 08:02:18 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [213.133.104.168] (HELO www168.your-server.de) (213.133.104.168) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 May 2013 08:02:11 +0000 Received: from [78.46.5.203] (helo=sslproxy01.your-server.de) by www168.your-server.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.74) (envelope-from ) id 1UeL2V-0004OS-Ae for users@pdfbox.apache.org; Mon, 20 May 2013 10:01:51 +0200 Received: from [93.207.111.176] (helo=mbp001.fritz.box) by sslproxy01.your-server.de with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1UeL2S-0004Ov-2O for users@pdfbox.apache.org; Mon, 20 May 2013 10:01:48 +0200 From: Maruan Sahyoun Content-Type: multipart/alternative; boundary="Apple-Mail=_C63762EA-11D3-4ACC-8A7A-209A07BB3C9D" Message-Id: Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Subject: Re: ClassCastException - cannot be cast to java.lang.Number on Date: Mon, 20 May 2013 10:01:46 +0200 References: To: users@pdfbox.apache.org In-Reply-To: X-Mailer: Apple Mail (2.1503) X-Authenticated-Sender: sahyoun@fileaffairs.de X-Virus-Scanned: Clear (ClamAV 0.97.6/17242/Mon May 20 06:41:49 2013) X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_C63762EA-11D3-4ACC-8A7A-209A07BB3C9D Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi Leo, would you have a sample pdf where the error occurs to try (please upload = to a public location as the mailing list doesn't allow attachments) = together with a sample input? BR Maruan Sahyoun Am 17.05.2013 um 17:24 schrieb Leonard Teo : > Hi guys, >=20 > 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. >=20 > 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. >=20 > Here is the source code: > https://gist.github.com/leonardteo/3b8567e7f747ef640b70 >=20 > The error is happening on line 93: >=20 > contentStream.setFont( font, fontSize ); >=20 >=20 > It works on many PDF's but there are enough of these errors that it is > causing problems with our users. >=20 > Any ideas what I'm doing wrong? >=20 > Thanks, >=20 > Leo >=20 >=20 > 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(PDSim= pleFont.java:454) > at = org.apache.pdfbox.pdmodel.font.PDSimpleFont.determineEncoding(PDSimpleFont= .java:422) > at = org.apache.pdfbox.pdmodel.font.PDType1Font.determineEncoding(PDType1Font.j= ava:269) > at org.apache.pdfbox.pdmodel.font.PDFont.(PDFont.java:194) > at = org.apache.pdfbox.pdmodel.font.PDSimpleFont.(PDSimpleFont.java:84) > at = org.apache.pdfbox.pdmodel.font.PDType1Font.(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(PDPageContentSt= ream.java:308) > at PDFStamper.stamp(PDFStamper.java:96) > at PDFStamper.main(PDFStamper.java:128) --Apple-Mail=_C63762EA-11D3-4ACC-8A7A-209A07BB3C9D--