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

PDFStreamEngine.showTextStrings with font switch

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.26
    • 2.0.27, 3.0.0 PDFBox
    • Parsing
    • None

    Description

      The attached PDF fails to render with an PDFStreamEngine.showTextStrings with the following exception:
      "java.io.IOException: Unknown type COSName in array for TJ operation:COSName{F3}"

      This seems to be a font switch.

      diff --git "a/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java" "b/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java"
      index e4f2259a5..12edadd2b 100644
      --- "a/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java"
      +++ "b/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java"
      @@ -680,6 +680,18 @@ public abstract class PDFStreamEngine
                       byte[] string = ((COSString)obj).getBytes();
                       showText(string);
                   }
      +            else if (obj instanceof COSName)
      +            {
      +                if(((COSName) obj).getName().startsWith("F"))
      +                {
      +                    textState.setFont(resources.getFont((COSName) obj));
      +                }
      +                else
      +                {
      +                    throw new IOException("Unknown type " + obj.getClass().getSimpleName()
      +                            + " in array for TJ operation:" + obj);
      +                }
      +            }
                   else if (obj instanceof COSArray)
                   {
                       LOG.error("Nested arrays are not allowed in an array for TJ operation:" + obj);
      

      Attachments

        Activity

          People

            tilman Tilman Hausherr
            Schmidor Oliver Schmidtmer
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: