You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2020/05/11 05:33:00 UTC
[jira] [Commented] (PDFBOX-4828) Encode a text using the vertical
type of the font in the attachment, which succeeded in version 2.0.12 but
failed in version 2.0.19
[ https://issues.apache.org/jira/browse/PDFBOX-4828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17104085#comment-17104085 ]
Tilman Hausherr commented on PDFBOX-4828:
-----------------------------------------
Thank you... 2.0.17 is the first version that fails
{noformat}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 60
at org.apache.fontbox.ttf.GlyphSubstitutionTable.getFeatureRecords(GlyphSubstitutionTable.java:418)
at org.apache.fontbox.ttf.GlyphSubstitutionTable.getSubstitution(GlyphSubstitutionTable.java:532)
at org.apache.fontbox.ttf.SubstitutingCmapLookup.getGlyphId(SubstitutingCmapLookup.java:45)
at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:337)
at org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:415)
at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:342)
at org.apache.pdfbox.pdmodel.PDPageContentStream.showTextInternal(PDPageContentStream.java:514)
at org.apache.pdfbox.pdmodel.PDPageContentStream.showText(PDPageContentStream.java:476)
at com.mycompany.mavenpdfboxtest.PDFBOX4828.main(PDFBOX4828.java:44) {noformat}
> Encode a text using the vertical type of the font in the attachment, which succeeded in version 2.0.12 but failed in version 2.0.19
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: PDFBOX-4828
> URL: https://issues.apache.org/jira/browse/PDFBOX-4828
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.19
> Reporter: bai yuan
> Priority: Major
> Attachments: ARIALUNI.TTF, Test1.java
>
>
> [^ARIALUNI.TTF] [^Test1.java]ARIALUNI.TTF^!/jira/images/icons/link_attachment_7.gif|width=7,height=7,align=absmiddle!^
> Run the follows code use 2.0.12, the text can be successfully encoded. Run this code use 2.0.19, the text can't be encoded.
> {code:java}
> public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException { System.setProperty("sun.java2d.cmm", "sun.java2d.cmm.kcms.KcmsServiceProvider"); PDDocument doc = new PDDocument(); PDPage page = new PDPage(PDRectangle.A4); doc.addPage(page);
> File file = new File("ARIALUNI.TTF"); PDType0Font ttFont = PDType0Font.loadVertical(doc, file); PDPageContentStream contentStream1 = new PDPageContentStream(doc, page); contentStream1.beginText(); contentStream1.newLineAtOffset(100, 100);
> String text = "电信"; if(isCharacterEncodeable(text, ttFont)) { contentStream1.setFont(ttFont, 12); contentStream1.showText(text); } contentStream1.endText(); contentStream1.close(); doc.save("export.pdf");
> doc.close(); System.out.println("aaaaa"); } private static boolean isCharacterEncodeable(String text, PDFont font){ try { font.encode(text); return true; } catch (Exception e) { return false; } }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org