apologies if this should have gone to the u...@pdfbox.apache.org using PDFBox-app-2.0.0-RC2.jar
here's a code fragment that should illustrate my problem: import java.io.ByteArrayOutputStream; import java.io.IOException; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.apache.pdfbox.pdmodel.font.PDFont; import org.apache.pdfbox.pdmodel.font.PDType1Font; public class Test { //-------------------------------------------------------- public static void main(String[] args) { ByteArrayOutputStream printDataBaos = new ByteArrayOutputStream(1000); PDDocument pdDoc = new PDDocument(); PDRectangle pageSizeRect = new PDRectangle(612f, 792f); PDPage pdPage = new PDPage(pageSizeRect); try { PDPageContentStream pdContent = new PDPageContentStream(pdDoc, pdPage); PDFont font = PDType1Font.HELVETICA; pdContent.setFont(font, 18); // Encoding encoding = ((PDSimpleFont) font).getEncoding(); // Map<Integer,String> map = encoding.getCodeToNameMap(); // for (Map.Entry entry : map.entrySet()) { // System.out.println(entry.getKey() + " = " + entry.getValue()); // } // ... // 127 = bullet // 129 = bullet // 141 = bullet // 143 = bullet // 144 = bullet // 149 = bullet (\u0095) // 157 = bullet // ... // 183 = periodcentered (\u00B7) // ... pdContent.beginText(); pdContent.newLineAtOffset(50f, 700f); // pdContent.showText("test "); // works // pdContent.showText("\u0095 test"); // IllegalArgumentException: No glyph for U+0095 in font Helvetica pdContent.showText("\u00B7 test"); // NullPointerException pdContent.endText(); pdContent.close(); pdDoc.addPage(pdPage); pdDoc.save(printDataBaos); pdDoc.close(); } catch (IOException ioe) { throw new RuntimeException(ioe); } } } my Java JRE version is 1.8.0_65 my Java runtime encoding is "Windows-1252" I'm running up-to-date Windows 7 the original stack trace using \u0095 (149): Exception in thread "main" java.lang.IllegalArgumentException: No glyph for U+0095 in font Helvetica at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:353) at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:283) at org.apache.pdfbox.pdmodel.PDPageContentStream.showText(PDPageContentStre am.java:341) at com.asc.powerlender.businessrules.print.PDFDocPrinter.printAt(PDFDocPrin ter.java:322) stack trace when using \u00B7 (183): Exception in thread "main" java.lang.NullPointerException at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:357) at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:283) at org.apache.pdfbox.pdmodel.PDPageContentStream.showText(PDPageContentStre am.java:341) at com.asc.powerlender.businessrules.print.PDFDocPrinter.printAt(PDFDocPrin ter.java:322) -----Original Message----- From: John Liston Sent: Friday, January 08, 2016 8:38 AM To: Mike Liston Subject: FW: printing the dot (\u0095) character using Helvetica... Did you join the email list? Did you get this response? -----Original Message----- From: Tilman Hausherr [mailto:thaush...@t-online.de] Sent: Friday, January 08, 2016 2:44 AM To: dev@pdfbox.apache.org Subject: Re: printing the dot (\u0095) character using Helvetica... Am 07.01.2016 um 20:15 schrieb Mike Liston: > I was able to do this with PDFBox 1.8.x but get a 'no glyph for /u0095 > in Helvetica' error with PDFBox 2.0 RC2. I don't want to embed a TTF > font. any help would be appreciated. thanks in advance. > > What about U+00B7, does that one work? --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org