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

FDFField.writeXML KO with String

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.8
    • 2.0.9, 3.0.0 PDFBox
    • AcroForm

    Description

      When saving an XFDF into file, all the `<value>` are skiped in the output.

      This is due to an incoherence between `writeXML()` which use `value instanceof COSString`

       public void writeXML(Writer output) throws IOException
          {
              output.write("<field name=\"" + getPartialFieldName() + "\">\n");
              Object value = getValue();
              if (value != null)
              {
                  if (value instanceof COSString)
                  {
                      output.write("<value>" + escapeXML(((COSString) value).getString()) + "</value>\n");
                  }
                  else if (value instanceof COSStream)
                  {
                      output.write("<value>" + escapeXML(((COSStream) value).toTextString()) + "</value>\n");
                  }
              }
      

      and `getValue()` which transform COSString into String :

       public Object getValue() throws IOException
          {
              COSBase value = field.getDictionaryObject(COSName.V);
              if (value instanceof COSName)
              {
                  return ((COSName) value).getName();
              }
              else if (value instanceof COSArray)
              {
                  return COSArrayList.convertCOSStringCOSArrayToList((COSArray) value);
              }
              else if (value instanceof COSString)
              {
                  return ((COSString) value).getString();
              }
      

      Attachments

        Activity

          People

            msahyoun Maruan Sahyoun
            loic oudot Loic
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: