Forum How do I...?

colspan-Attribute

Anonymous
Hello,
first I have to say, that PrinceXML is a really great tool.
But at the moment I have a problem: I want to convert some xhtml code to pdf. Okay, that works, but if my source looks like that:
<table>
<tr>
<th colspan=5>title</th>
</tr>
<tr>
<th width=20>text</th>
<th>Text </th>
<th width=100>text</th>
<th width=100>text</th>
<th width=100>text</th>
</tr>
<tr>
<td>
...
</tr>
...
</table>

I think prince has a problem with the colspan-attribute, could that be possible? (even if I set the table-layout to fixed). So the result is, that my first row, the title-row woorks preety well, but the other "<th>" elements have this width as defined in the source and for the rest of the table, there are 4 more columns with a border around them.
Okay, its hard to describe ;)
If i remove the "colspan" attribute, I get a better result, but the same problem as mentioned before appears in the first table-row (title) and the other table colums have exactly the same width (20%).
Thats not really fine, because I want to create PDFs that are looking like nearly the same as my website does.
Have you any ideas how I can solve that problem?
thanks a lot!
Lynx
Prince natively supports XML and CSS and formats XHTML documents using default CSS style sheet. It can handle HTML documents that are converted into XHTML, but it is better not to rely on conversion and write documents directly in X(HT)ML + CSS.
So instead of presentational attributes like width="100" it is better to use appropriate CSS like style="width:100px". Colspan attribute should work (excluding colspan="0" value), however please follow XML syntax and enclose attribute values in quotes (colspan="5" instead of colspan=5).
Anonymous
Thanks for the answer. For sure I am using colspan="5" instead of colspan=5, it was just for demonstration, so that should not be the problem. I am converting html to xhtml and then to xml with jtidy. I think the syntax must be correct. I cannot write the code directly in xml, because its a really big project and its too late to do that ;)
mikeday
As Lynx said, Prince does not yet support most of the presentational attributes in HTML, so the width attribute will have no effect:

<td width="100">...</td>

but the width CSS property should do the trick:

<td style="width: 100px">...</td>

We may add support for more HTML presentational attributes to a future version of Prince.
Anonymous
Hi,
okay, thanks a lot, the width works now, but what is still not working is, that, if I am using the "colspan"-attribute in title, but not in the other table-rows/cells, there are on the right end of each row some small cells (width ca. 3-5px) with a border around them and if I am using a background-color thats a little bit bad. The problem is, that I cannot remove the colspan attribute. I cannot remove the border, in that case that would be no problem and I'm sure that I did not set any border in CSS. I would not recognize the problem if there would not be any border.. could this be because of prince or am I doing something wrong?

I hope you can now imagin how it looks like:


| - - - - - t a b l e t i t l e - - - - - - - - - - |
|text|text----|--text----|text|text| | | | |
|text|text----|--text----|text|text| | | | |
|text|text----|--text----|text|text| | | | |

Thanks for help!
mikeday
This sounds like an issue affecting table column widths in the presence of colspan cells that we just fixed in a maintenance release of Prince 5.1, available for download today.

Please give the new version a try and see if it solves the problem! :)
Anonymous
Thanks a lot, it works great now!! :)