Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-3277

Unable to write Chinese characters into PDF

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: None
    • Component/s: PDModel, Writing
    • Labels:
      None
    • Environment:
      Windows, JDK7

      Description

      Please refer to the JIRA

      https://issues.apache.org/jira/browse/PDFBOX-1705

      I am unable to write Chinese content into a PDF using EmbeddedFonts.java from JIRA 1705. Later I found way to fix it by feeding in the "arialuni.ttf" instead of LiberationSans-Regular.ttf from the example. I had confirmed the Chinese PDF generation by writing a hardcoded Chinese data in my example.

      Later I had extended this piece of logic to write the desired PDF in my application but got into "java.lang.IllegalArgumentException: U+008A is not available in this font's encoding: WinAnsiEncoding". Please advise.

      1. From my application, i call an external Webservice and that returns the Chinese + English content in response as a String,
      2. I read this response string using UTF-8 as the Charset and unmarshal it to Java bean using JAXRB.
      3. To the contentStream.drawString() i passed the string calling the getter method on the pojo which has Chinese data stored in a String variable. Here's where i am getting the above exception. Please help me to fix this.
      I am using PDFBox version 2.0.0.-RC3. Your help is much appreciated.

      Also the generated PDF file is on MBs, i believe this huge size is because of the feed of arialuni.ttf which is of size 23 MB.Is there a way we can reduce the size of the output PDF file. Do we have an alternate to arialuni.ttf? Please advise.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              trajang Tiruppathi Rajan Gunaseelan
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: