I am getting cryptic error messages trying to render a pdf file using xml:
Exception at /url/
('Unable to generate PDF.', b'Exception\norg.apache.fop.apps.FOPException: org.apache.fop.fo.ValidationException:
The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table.
(See position 31:15)\njavax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException:
The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table. (See position 31:15)\n\n')
The only thing I'm changing is the <column name="Record date Ex-dividend date Payable Date" size="4.2cm"></column>
. This matches the format the pdf was made with in Perl, and removing that one column line fixes the pdf and it works.
{% block pages %}
<schedule_page>
<columns>
<column name="Record date Ex-dividend date Payable Date" size="4.2cm"></column>
{% for date_set in dist_dates %}
<column name="{{ date_set.record_date|date:'j-M' }} {{ date_set.ex_date|date:'j-M' }} {{ date_set.pay_date|date:'j-M' }}" size="1.675cm" margin="0.1cm"></column>
{% endfor %}
</columns>
<data>
{% regroup portfolios by group as portfolio_groups %}
{% for portfolio_group in portfolio_groups %}
<group name="{{ portfolio_group.grouper }}">
{% for portfolio in portfolio_group.list %}
<fund name="{{ portfolio.name }}">
{% for dist in portfolio.distributions %}
<cell value="{{ dist.value }}" {% if dist.value %}margin="0.1cm"{% endif %} ></cell>
{% endfor %}
</fund>
{% endfor %}
</group>
{% endfor %}
</data>
</schedule_page>
{% endblock %}
The fo file that precedes the pdf looks like:
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="letter-landscape" page-height="21.59cm" page-width="27.94cm" margin-top="1.0cm" margin-bottom="0.5cm" margin-left="0.97cm" margin-right="0.97cm">
<fo:region-body margin-top="3.5cm" margin-bottom="1.0cm"/>
<fo:region-before extent="4.0cm"/>
<fo:region-after extent="1.0cm"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="DistributionPage">
<fo:repeatable-page-master-reference master-reference="letter-landscape"/>
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="DistributionPage">
<fo:static-content flow-name="xsl-region-before">
<fo:table font-size="8pt" font-family="TradeGothicCondensed" border-collapse="separate" table-layout="fixed">
<fo:table-body>
<fo:table-row>
<fo:table-cell margin-bottom="8pt" number-columns-spanned="0">
<fo:block font-weight="bold" font-size="24pt" font-family="TradeGothicCondensed" text-align="left">Distributions</fo:block>
</fo:table-cell>
<fo:table-cell margin-bottom="8pt" vertical-align="top" text-align="right" number-columns-spanned="0">
<fo:block space-after="8pt" margin-bottom="8pt" vertical-align="top">
<fo:external-graphic content-width="1.5in" src="url(static/logo.jpg)"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block/>
</fo:table-cell>
<fo:table-cell padding-bottom="4pt" margin-bottom="4pt" padding-left="4pt" number-columns-spanned="0">
<fo:block padding-bottom="4pt" margin-bottom="4pt" margin-left="4pt" padding-left="4pt" text-align="center" border-bottom-color="black" border-bottom-width="0.7pt" border-bottom-style="solid">
Estimated
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row/>
<fo:table-row>
<fo:table-cell border-top-color="black" border-top-width="0.7pt" border-top-style="solid">
<fo:block/>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:table padding-top="0.1cm" font-size="8pt" font-family="TradeGothicCondensed" border-collapse="separate" table-layout="fixed">
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block line-height="10pt" font-size="8pt" text-align="left">Our disclaimer.</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block vertical-align="bottom" line-height="10pt" font-family="TradeGothicCondensed" font-size="8pt" text-align="right">
Page
<fo:page-number/> /
<fo:page-number-citation ref-id="last-page"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="TradeGothicCondensed" border-collapse="separate" table-layout="fixed">
<fo:table-body font-family="TradeGothicCondensed">
<fo:table-row>
<fo:table-cell>
<fo:block font-weight="bold" font-size="14pt" font-family="TradeGothicCondensed" text-align="left" number-columns-spanned="0"/>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block line-height="13pt" font-weight="bold">A portfolio name</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell display-align="after">
<fo:block line-height="12pt" padding-left="3pt" vertical-align="top" text-align="left">A portfolio name</fo:block>
</fo:table-cell>
</fo:table-row>
...etc...
Why is adding this single line blowing up my pdf download? Thank you
It looks like that, with FOP, you need one fo:table-column
for each column in the table or you need none.
The XSL 1.1 Recommendation doesn't require that, AFAICT, but it also doesn't say what happens for a mismatch in column counts.
Since you say you remove one line and produce no fo:table-column
, and since you are seemingly also generating fo:table-column
based on dist_dates
and generating fo:table-cell
based on portfolio information, it seems like your logic to generate fo:table-column
isn't quite right. Unless you need the width or other properties set on the fo:table-column
, there's no harm done if you omit them.