473,372 Members | 1,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Suggestions for creating a PDF table

Short question:

Is there a good library for generating HTML-style tables with the equivalent
of colspans, automatically sized columns, etc. that can render directly to
PDF?

Longer question:

I'm re-doing a big chunk of locally-written code. I have a
report-generating function that takes a list of lists of lists as input and
returns either a PDF, an HTML table, or an Excel spreadsheet as requested.
For example, input might look like:

makereport('html',
headers=['Invoice number', 'Customer', 'Price'],
data=[
[['123', 'John Doe', '$50.00'],
['Ordered on 2008-01-01 via the website']],
[['124', 'Peter Bilt', '$25.99'],
['Mail via African swallow']]
])

This would result in HTML like:

<table>
<tr>
<th>Invoice number</th>
<th>Customer</th>
<th>Price</th>
</tr>
<tr class="lightbackground">
<td>123</td>
<td>John Doe</td>
<td>$50.00</td>
</tr>
<tr class="lightbackground">
<td colspan="3">Ordered on 2008-01-01 via the website</td>
</tr>
<tr class="darkerbackground">
<td>124</td>
<td>Peter Bilt</td>
<td>$25.99</td>
</tr>
<tr class="darkerbackground">
<td colspan="3">Mail via African swallow</td>
</tr>
</table>

Note particularly how the explanatory notes for each invoice are similar in
appearance to the "primary" report lines they're associated with.

Now, I have a similar transformation to PDF via pdflatex. This works fairly
well but requires a bunch of temp files and subprocesses, and I've never
been 100% happy with the LaTeX output (you have to calculate your own
column widths, for instance). Since I plan to re-write this anyway, I'd
like to find a more widely used library if one was available.

ReportLab seemed *almost* perfect, except that it doesn't support colspans.
As I hope I demonstrated in the example, most of our reports depend on that
ability.

So, again, any thoughts on a PDF generator that can generate tables with the
same kind of flexibility as HTML?
--
Kirk Strauser
Jul 28 '08 #1
2 1157
Kirk Strauser wrote:
Short question:

Is there a good library for generating HTML-style tables with the equivalent
of colspans, automatically sized columns, etc. that can render directly to
PDF?

Longer question:

I'm re-doing a big chunk of locally-written code. I have a
report-generating function that takes a list of lists of lists as input and
returns either a PDF, an HTML table, or an Excel spreadsheet as requested.
For example, input might look like:

makereport('html',
headers=['Invoice number', 'Customer', 'Price'],
data=[
[['123', 'John Doe', '$50.00'],
['Ordered on 2008-01-01 via the website']],
[['124', 'Peter Bilt', '$25.99'],
['Mail via African swallow']]
])

This would result in HTML like:

<table>
<tr>
<th>Invoice number</th>
<th>Customer</th>
<th>Price</th>
</tr>
<tr class="lightbackground">
<td>123</td>
<td>John Doe</td>
<td>$50.00</td>
</tr>
<tr class="lightbackground">
<td colspan="3">Ordered on 2008-01-01 via the website</td>
</tr>
<tr class="darkerbackground">
<td>124</td>
<td>Peter Bilt</td>
<td>$25.99</td>
</tr>
<tr class="darkerbackground">
<td colspan="3">Mail via African swallow</td>
</tr>
</table>

Note particularly how the explanatory notes for each invoice are similar in
appearance to the "primary" report lines they're associated with.

Now, I have a similar transformation to PDF via pdflatex. This works fairly
well but requires a bunch of temp files and subprocesses, and I've never
been 100% happy with the LaTeX output (you have to calculate your own
column widths, for instance). Since I plan to re-write this anyway, I'd
like to find a more widely used library if one was available.

ReportLab seemed *almost* perfect, except that it doesn't support colspans.
As I hope I demonstrated in the example, most of our reports depend on that
ability.

So, again, any thoughts on a PDF generator that can generate tables with the
same kind of flexibility as HTML?
It does support the equivalent of colspans. See page 75 of the userguide manual.

-Larry
Jul 28 '08 #2
Kirk Strauser wrote:
Short question:

Is there a good library for generating HTML-style tables with the equivalent
of colspans, automatically sized columns, etc. that can render directly to
PDF?

Longer question:

I'm re-doing a big chunk of locally-written code. I have a
report-generating function that takes a list of lists of lists as input and
returns either a PDF, an HTML table, or an Excel spreadsheet as requested.
For example, input might look like:

makereport('html',
headers=['Invoice number', 'Customer', 'Price'],
data=[
[['123', 'John Doe', '$50.00'],
['Ordered on 2008-01-01 via the website']],
[['124', 'Peter Bilt', '$25.99'],
['Mail via African swallow']]
])
<snip>
Now, I have a similar transformation to PDF via pdflatex. This works fairly
well but requires a bunch of temp files and subprocesses, and I've never
been 100% happy with the LaTeX output (you have to calculate your own
column widths, for instance). Since I plan to re-write this anyway, I'd
like to find a more widely used library if one was available.

<snip>

Short answer: LaTeX should be good. Use XML source; XSLT to TeXML; TeXML
to LaTeX ( uses a python program); compile to PDF.

Longer answer: Can you provide a minimal example of the kind of
LaTeX source you would ideally like ?

If not, your problem is with LaTeX itself, which has if anything
__too_many__ ways of controlling tables rather than inadequate
ways. If so, we may be able to help with the rather arcane
transformation into TeXML format.

As for all the temp files that LaTeX creates, they are easily dealt
with using a makefile or whatever.

Bye for now,
Ken
Aug 8 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: Neil | last post by:
I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back end. I currently have a selections table in the front end file which the users use to make selections of records. The table...
7
by: John Baker | last post by:
Hi: I would like to know how to create a temp DB to store the data in a table while I do something else with the table. Specifically, how do I create the temp remove the temp I want to be...
7
by: Susan Bricker | last post by:
Greetings. As a relative newcomer to Access, I am having trouble deciding on how to design the form flow for updating and creating related records. I'm looking for a variety of suggestions so...
4
by: Coleen | last post by:
Hi All :-) Can anyone give me a URL where I can find a good example of code on how to create a temporary SQL table using VB.net? I've checked the Microsoft site at: ...
1
by: Ddraig | last post by:
Howdy, I've got a little project going and I am trying to figure out a good way to do this. But since I'm still learning I'm probably missing a few obvious steps. Also not sure if I have my...
1
by: Ddraig | last post by:
Howdy, I've got a little project going and I am trying to figure out a good way to do this. But since I'm still learning I'm probably missing a few obvious steps. Also not sure if I have my...
2
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: ...
2
by: graeme.alford | last post by:
I am creating a database to track connections on a fibre optic cabling network. Individual fibres can be connected to network equipment ports or to fibres on another cable via patchleads. Fibres...
6
by: firefighter17103 | last post by:
Hi All, I am new to MS Access 07, & do not know any VB, on a new business adventure. I am running Office07 on Vista Home Premium. I am in the process of creating a database that in the end I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.