Home
Analytics
How to render HTML-tables to pdf
WFG
Hi there.
I'm trying to render a text-field (content-type HTML) with a table ("<table><tr><td>column1</td>...") to a pdf-output.
No matter what I try, nothing seems to work.
It seems, that a <td>-tag gives rise to start new columns in the resulting pdf, but they can't be formatted!
Everything works fine (table-border, column-alignment) as long, as I render to HTML...
I found lots of bugzilla-entries about this issue, all marked checked in (from 2005 up to may, 2007).
Any idea?
many thanks.
Find more posts tagged with
Comments
JasonW
Can you post an example table you want to render? Also what version of BIRT are you using?
Jason
WFG
<blockquote class='ipsBlockquote' data-author="JasonW"><p>Can you post an example table you want to render? Also what version of BIRT are you using?<br />
<br />
Jason</p></blockquote>
<br />
Jason.<br />
Many thanks first. The sample-table is quite simple. It's anything like:<br />
<br />
<table width="100%"> -- the width-attribute will be ignored!<br />
<tr><br />
<td><br />
Column1<br />
</td><br />
</tr><br />
<tr><br />
<td align="right"> -- the allign-attribute wil also be ignored<br />
1234.56<br />
</td><br />
</tr><br />
</table><br />
<br />
I place this in a Text-Field (content-type: HTML [of course]) and render it with BIRT 2.1.1. Engine to pdf without effect (or to an HTML-output and everything's fine).<br />
Also, if I open such a design with 2.2.2. deseigner, the preview in HTML is fine while the pdf-preview doesn't take any effect. Even if I leave the <table>- and the <tr>-tags, the pdf-render-engine will take the <td> - tags and build some columns - but still not interested in the attributes...<br />
<br />
Does this help (to help me
) )?<br />
Many thanks again<br />
Wil
jimp
I am sorry to post this unrelated issue because I can not find any link to allow me to post a new topic. Please help me.
JasonW
Jimp,
Select the Forum Tools Dropdown.
Jason
JasonW
Wil,
I understand now. The table displays but the formatting is not applied. Can you log a bugzilla entry for this?
Jason
WFG
<blockquote class='ipsBlockquote' data-author="JasonW"><p>Wil,<br />
<br />
I understand now. The table displays but the formatting is not applied. Can you log a bugzilla entry for this?<br />
<br />
Jason</p></blockquote>
<br />
Thanks Jason.<br />
That's what I'll do.<br />
Beside this, I'm trying to run the whole Birt-Project to see, if there is an easy way to adjust columns in the pdf emitter (found a good candidate in PDFPage.java) but I can't run the pdf emitter.<br />
I did it the easy way: I checked out the sources via CVS. Then, when the the whole project was built (had to resolve a few errors) I added another simple project to the workspace that runs the platform/engine. I can startup everthing, I can compile the .rptdocument file but the pdf-emitter won't run. Got a log like this (sorry for the german messages):<br />
<br />
09.05.2008 09:59:49 org.eclipse.birt.report.engine.api.impl.EngineTask createContentEmitter<br />
SCHWERWIEGEND: Report engine can not create pdf emitter.<br />
09.05.2008 09:59:49 org.eclipse.birt.report.engine.api.impl.RenderTask render<br />
SCHWERWIEGEND: An error happened while running the report. Cause:<br />
org.eclipse.birt.report.engine.api.EngineException: Report engine fails to initialize pdf emitter, please make sure required libraries for this emitter are installed.<br />
at org.eclipse.birt.report.engine.api.impl.EngineTask.createContentEmitter(EngineTask.java:1034)<br />
at org.eclipse.birt.report.engine.api.impl.RenderTask$PageRangeRender.render(RenderTask.java:466)<br />
at org.eclipse.birt.report.engine.api.impl.RenderTask.render(RenderTask.java:254)<br />
at PrintJob.PrintPDF(PrintJob.java:370)<br />
at PrintJob.run(PrintJob.java:98)<br />
at java.lang.Thread.run(Unknown Source)<br />
09:59:49 org.eclipse.birt.report.engine.api.EngineException: Report engine fails to initialize pdf emitter, please make sure required libraries for this emitter are installed.<br />
<br />
While debugging the session, I ran through the PDFEmitter's Constructor. But actually, I really don't know, what happens there.<br />
<br />
Can you give some newby-advice? The idea is to fix the table/alignment.problem locally until it's fixed in the next BIRT-Release.<br />
<br />
Many thanks again<br />
Wil
JasonW
Wil,
Did the org.eclipse.birt.report.engine.emitter.pdf project build without any errors?
The class you should probably look at is the HTML2Content class. I did some more testing and got yours table to work with using inline styles. These seem to get picked up by the style processor. Try this.
<table style="width: 100%">
<tr>
<td>
Column1
</td>
</tr>
<tr>
<td style="text-align: right">
1234.56
</td>
</tr>
</table>
Jason
WFG
<blockquote class='ipsBlockquote' data-author="JasonW"><p>Wil,<br />
<br />
Did the org.eclipse.birt.report.engine.emitter.pdf project build without any errors?<br />
<br />
The class you should probably look at is the HTML2Content class. I did some more testing and got yours table to work with using inline styles. These seem to get picked up by the style processor. Try this.<br />
<br />
<table style="width: 100%"> <br />
<tr><br />
<td><br />
Column1<br />
</td><br />
</tr><br />
<tr><br />
<td style="text-align: right"> <br />
1234.56<br />
</td><br />
</tr><br />
</table><br />
<br />
Jason</p></blockquote>
<br />
THAT'S IT!!!<br />
Using css (or inline style) is exactly what I forgot!<br />
So, it's not needed to compile (and "fix") BIRT. I simply have to change the "table-generation-process" (it's programmed).<br />
many many thanks again.