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

ToUnicode CMap is not written correctly when the entry count is just 100.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.11
    • 2.0.12, 3.0.0 PDFBox
    • PDModel
    • None
    • Windows10

    Description

      The following warning log is output when I execute attached PDFSample.java.
      org.apache.pdfbox.pdmodel.font.PDFont <init>
      WARN: Invalid ToUnicode CMap in font AAKCFF+IPAMincho
      org.apache.pdfbox.pdmodel.font.PDType0Font toUnicode
      WARN: No Unicode mapping for CID+598 (598) in font AAKCFF+IPAMincho
      :

      This program creates a simple japanese pdf and read the image.
      This program reads a font file. You can download the file from the following URL.
      https://ipafont.ipa.go.jp/old/ipafont/download.html#en

      I investigated the problem and found a bug in ToUnicodeWriter class.
      In writeTo method, a loop count in a operator is calculated by the following line. But the count will be 0 if the srcFrom size is just 100.
      int count = batch == batchCount - 1 ? srcFrom.size() % 100 : 100;

      I changed this line to below and I confirmed that the problem was resolved.
      int count = batch == batchCount - 1 ? srcFrom.size() - 100 * batch : 100;

      Attachments

        1. pdf_sample.pdf
          23 kB
          Atsushi Doita
        2. PDFSample.java
          2 kB
          Atsushi Doita

        Activity

          People

            tilman Tilman Hausherr
            Atsushi433 Atsushi Doita
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: