You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Friediwn Fleischmn (JIRA)" <ji...@apache.org> on 2016/03/31 10:37:25 UTC

[jira] [Updated] (PDFBOX-3298) Can't show text (glyph) from ZapfDingbats font

     [ https://issues.apache.org/jira/browse/PDFBOX-3298?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Friediwn Fleischmn updated PDFBOX-3298:
---------------------------------------
    Description: 
I am unable to add glyphs from the standard *ZapfDingbats* font to a PDF document. The issue seems to be that the encoding for the font (*WinAnsiEncoding*) does not have mappings for the "non-ASCII (???)" PDF names used in the font ("aXX"). (However, the {{PDSimpleFont.glyphList}} *does* contain mappings between Unicode codepoints and PDF names.)

Sample code:
{code}
PDDocument document = PDDocument.load(new File("myfile.pdf"));
PDPage page = document.getPages().get(0); // first page
PDPageContentStream contentStream = new PDPageContentStream(document, page, AppendMode.APPEND, true);

PDType1Font font = PDType1Font.ZAPF_DINGBATS;
String glyph = "\u2714";

contentStream.beginText();
contentStream.setFont(font, fontSize);
contentStream.newLineAtOffset(10, 10); // towards lower left corner of page
contentStream.showText(glyph);
contentStream.endText();
contentStream.close();

document.save("output.pdf");
document.close();
{code}

Exception thrown:
{code}
Exception in thread "main" java.lang.IllegalArgumentException: U+2714 ('a20') is not available in this font's encoding: WinAnsiEncoding
    at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:345)
    at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
    :
{code}



  was:
I am unable to add glyphs from the standard *ZapfDingbats* font to a PDF document. The issue seems to be that the encoding for the font (*WinAnsiEncoding*) does not have mappings for the "non-ASCII (???)" PDF names used in the font ("aXX"). (However, the {{PDSimpleFont.glyphList}} *does* contain mappings between Unicode codepoints and PDF names.)

Sample code:
{code}
PDDocument document = PDDocument.load(new File("myfile.pdf"));
PDPage page = document.getPages().get(0); // first page
PDPageContentStream contentStream = new PDPageContentStream(document, page, AppendMode.APPEND, true);

PDType1Font font = PDType1Font.ZAPF_DINGBATS;
String glyph = "\u2714";

contentStream.beginText();
contentStream.setFont(font, fontSize);
contentStream.newLineAtOffset(10, 10); // towards lower left corner of page
contentStream.showText(glyph);
contentStream.endText();
contentStream.close();

document.save("output.pdf");
document.close();
{code}

Exception thrown:
{code}
Exception in thread "main" java.lang.IllegalArgumentException: U+2714 ('a20') is not available in this font's encoding: WinAnsiEncoding
    at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:345)
    at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
    :
{codel}




> Can't show text (glyph) from ZapfDingbats font
> ----------------------------------------------
>
>                 Key: PDFBOX-3298
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3298
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 2.0.0
>         Environment: Linux (kernel "3.19.0-32 generic"), Java "build 1.8.0_66-b17".
>            Reporter: Friediwn Fleischmn
>              Labels: newbie
>
> I am unable to add glyphs from the standard *ZapfDingbats* font to a PDF document. The issue seems to be that the encoding for the font (*WinAnsiEncoding*) does not have mappings for the "non-ASCII (???)" PDF names used in the font ("aXX"). (However, the {{PDSimpleFont.glyphList}} *does* contain mappings between Unicode codepoints and PDF names.)
> Sample code:
> {code}
> PDDocument document = PDDocument.load(new File("myfile.pdf"));
> PDPage page = document.getPages().get(0); // first page
> PDPageContentStream contentStream = new PDPageContentStream(document, page, AppendMode.APPEND, true);
> PDType1Font font = PDType1Font.ZAPF_DINGBATS;
> String glyph = "\u2714";
> contentStream.beginText();
> contentStream.setFont(font, fontSize);
> contentStream.newLineAtOffset(10, 10); // towards lower left corner of page
> contentStream.showText(glyph);
> contentStream.endText();
> contentStream.close();
> document.save("output.pdf");
> document.close();
> {code}
> Exception thrown:
> {code}
> Exception in thread "main" java.lang.IllegalArgumentException: U+2714 ('a20') is not available in this font's encoding: WinAnsiEncoding
>     at org.apache.pdfbox.pdmodel.font.PDType1Font.encode(PDType1Font.java:345)
>     at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:286)
>     :
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org