[ 
https://issues.apache.org/jira/browse/PDFBOX-3504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15507359#comment-15507359
 ] 

John Hewson edited comment on PDFBOX-3504 at 9/20/16 6:43 PM:
--------------------------------------------------------------

PDType0Font supports Unicode for any language which doesn't require [complex 
text layout|https://en.wikipedia.org/wiki/Complex_text_layout]. The supported 
characters are determined by the font, not by PDFBox, so you'll have to inspect 
the fonts on your system.

If you're using a built-in PDType1Font, such as HELVETICA, which supports only 
WinAnsiEncoding, the [PDF 
specification|http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf]
 (Annex D) lists which characters are supported.


was (Author: jahewson):
PDType0Font supports Unicode and any language which doesn't require [complex 
text layout|https://en.wikipedia.org/wiki/Complex_text_layout]. The supported 
characters are determined by the font, not by PDFBox, so you'll have to inspect 
the fonts on your system.

If you're using a built-in PDType1Font, such as HELVETICA, which supports only 
WinAnsiEncoding, the [PDF 
specification|http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf]
 (Annex D) lists which characters are supported.

> Special characters issue
> ------------------------
>
>                 Key: PDFBOX-3504
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3504
>             Project: PDFBox
>          Issue Type: Bug
>          Components: FontBox
>    Affects Versions: 2.0.0, 2.0.3, 2.1.0
>         Environment: Test
>            Reporter: KUMARA SWAMY PALLUKURI
>            Assignee: Tilman Hausherr
>             Fix For: 2.0.4, 2.1.0
>
>
> special characters are not supporting in my program  
> eg: "α"(alpha)
> My sample code:
> {code}
> package com.test;
> import java.io.IOException;
> import java.util.ArrayList;
> import java.util.List;
> 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 SimpleTest {
>       public static void main(String[] args) throws Exception {
>               SimpleTest s = new SimpleTest();
>               s.pdfGeneration();
>       }
>       public void pdfGeneration() throws IOException {
>               String outputFileName = "Simple123.pdf";
>               // Create a document and add a page to it
>               PDDocument document = new PDDocument();
>               PDPage page1 = new PDPage(PDRectangle.A4);
>               // PDRectangle.LETTER and others are also possible
>               PDRectangle rect = page1.getMediaBox();
>               // rect can be used to get the page width and height
>               document.addPage(page1);
>               // Create a new font object selecting one of the PDF base fonts
>               PDFont fontPlain = PDType1Font.HELVETICA;
>               PDFont fontBold = PDType1Font.HELVETICA_BOLD;
>               PDFont fontItalic = PDType1Font.HELVETICA_OBLIQUE;
>               PDFont fontMono = PDType1Font.COURIER;
>               // Start a new content stream which will "hold" the to be 
> created
>               // content
>               PDPageContentStream cos = new PDPageContentStream(document, 
> page1);
>               int line = 0;
>               List<String> sampleData = new ArrayList<String>();
>               sampleData.add("ss1 s");
>               sampleData.add("dd α");
>               // String tt ="sss";
>               for (String tt : sampleData) {
>                       ++line;
>                       drawText(cos, fontPlain,  tt, rect, line);
>               }
>               cos.close();
>               document.save(outputFileName);
>               document.close();
>       }
>       public void drawText(PDPageContentStream cos, PDFont fontPlain,String 
> text,
>                       PDRectangle rect, int line) throws IOException {
>               try {
>                       cos.beginText();
>                       cos.setFont(fontPlain, 12);
>                       cos.newLineAtOffset(100, rect.getHeight() - 50 * 
> (line));
>                       cos.showText(text);
>                       cos.endText();
>               } catch (Exception e) {
>                       e.printStackTrace();
>               //      cos.endText();
>               } 
>       }
> }
> {code}
> Exception:
> {code}
> java.lang.IllegalArgumentException: U+03B1 ('alpha') 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)
>       at 
> org.apache.pdfbox.pdmodel.PDPageContentStream.showText(PDPageContentStream.java:411)
>       at com.test.SimpleTest.drawText(SimpleTest.java:67)
>       at com.test.SimpleTest.pdfGeneration(SimpleTest.java:50)
>       at com.test.SimpleTest.main(SimpleTest.java:18)
> {code}
> And also please let me know whether pdf box will supports for localization or 
> not?



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

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

Reply via email to