Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-3167

[PATCH] Tagging attribute for TH Scope is overwritten by span attributes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      If a table cell has the role TH it gets a scope info as PDF tag attribute (Entry A) with the name /Scope and a value Column (default), Row or Both.

      This works fine, but if the fo:table-cell has an additional number-columns-spanned attribute, the Scope info is lost.

      The attached FO document (scope-with-colspan.fo) shows two table head cells only one with number-columns-spanned=2.

      The screenshot shows the tag property view in Acrobat of the rendered PDF (scope-with-colspan.pdf) for both cells.

      One has the ColSpan attribute but no Scope info:

      The other with no ColSpan attribute has the Scope info:

      The reason for the behavior of FOP is that the scope is written directly as "A"-Entry:

                  static void addScopeAttribute(PDFStructElem th, Scope scope) {
                      PDFDictionary scopeAttribute = new PDFDictionary();
                      scopeAttribute.put("O", Table.NAME);
                      scopeAttribute.put("Scope", scope.getName());
                      th.put("A", scopeAttribute);
                  }
      

      Source: StandardStructureAttributes.java:58

      But the colspan/rowspan attributes are collected as a special attribute field of PDFStructElem:

          public void setTableAttributeColSpan(int colSpan) {
              setTableAttributeRowColumnSpan("ColSpan", colSpan);
          }
      
          public void setTableAttributeRowSpan(int rowSpan) {
              setTableAttributeRowColumnSpan("RowSpan", rowSpan);
          }
      
          private void setTableAttributeRowColumnSpan(String typeSpan, int span) {
              PDFDictionary attribute = new PDFDictionary();
              attribute.put("O", Table.NAME);
              attribute.put(typeSpan, span);
              if (attributes == null) {
                  attributes = new ArrayList<PDFDictionary>(2);
              }
              attributes.add(attribute);
          }
      

      Source: PDFStructElem.java:230

      At the end the field attribute overwrites the "A"-Entry:

          private void attachAttributes() {
              if (attributes != null) {
                  if (attributes.size() == 1) {
                      put("A", attributes.get(0));
                  } else {
                      PDFArray array = new PDFArray(attributes);
                      put("A", array);
                  }
              }
          }
      

      Source: PDFStructElem.java:174

      I will see If I can produce a patch in the next days.

      Attachments

        1. fop-3167.diff
          7 kB
          Nico Kutscherauer
        2. colspan-rowspan-cell-properties.JPG
          35 kB
          Nico Kutscherauer
        3. colspan-rowspan-tag-properties.JPG
          36 kB
          Nico Kutscherauer
        4. scope-with-colspan_headC.jpg
          70 kB
          Nico Kutscherauer
        5. scope-with-colspan_headA.jpg
          70 kB
          Nico Kutscherauer
        6. scope-with-colspan.pdf
          6 kB
          Nico Kutscherauer
        7. scope-with-colspan.fo
          2 kB
          Nico Kutscherauer

        Activity

          People

            Unassigned Unassigned
            nkutsche Nico Kutscherauer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: