[Seaside] WAComponent to PDF

Otto Behrens otto at finworks.biz
Thu Oct 22 16:38:21 UTC 2015


Hi,

We have been producing PDF documents for quite a while now with this
approach. We like the approach of using seaside because we write the
code once (to see it in the browser) and then trust that the look in
the PDF is good. We render html and write it to a file; then call a
program on the command line and read the resultant PDF back or email
it as an attachment.

We reference the CSS URL in the html header. This is quite important
because we want the tool to render the PDF correctly with the CSS. We
have a single CSS url (file) per site and use this same one for PDF.

We've used prince (www.princexml.com) for many years now and it has
been reliable. We also used chart director to generate charts / graphs
by producing an image which we reference in the html file and produce
a PDF with. We've now moved graphs and things to HighCharts, which
uses a lot of JavaScript to render the graphs. Many tools have
problems with executing JS and producing correct PDF. So we are in the
process of moving to wxhtmltopdf. We found that it uses the CSS
properly and that it works well with HighCharts.

Below is a method that may help. Our stuff is not that nicely
packaged. We also have diverse documents and several span a number of
pages, depending on data and various things. We had to do a bit of
work to handle widows & orphans, which we did in Seaside

 (WAHtmlCanvas builder fullDocument: true)
rootBlock: [ :root |
root context visitor: (WARenderingGuide client: root context visitor).
root title: 'Form'.
root meta contentType: (WAMimeType textHtml charset: 'utf-8').
root stylesheet url: self stylesheetFileFullPath.
self addAdditionalBookmarksForRowsToRootIfNecessary: root ];
yourself


HTH
Let me know if you need more.
Otto



On Thu, Oct 22, 2015 at 3:56 PM, Hilaire <hilaire at drgeo.eu> wrote:
> Hello,
>
> I would like to render WAComponents as PDF documents.
> I took at look at Artefact, but it is an important work to render again
> the data as PDF with Artefact, not to mention I feel it is a duplicated
> work. Moreover, I have quite long documents spanning over several pages,
> some of my tables are complex with some columns spanning over 2 or 3
> columns and I have about 50 different documents to turn as PDF file.
>
> Now I am think about rendering these components on dedicated pages, then
> using wkhtmltopdf.
> What I would do is get these components rendered at dedicated urls, then
> call wkhtmltopdf with these urls as arguments.
> Practically how will you do that? How to forge an URL for a page
> rendering the component with a dedicated decoration for PDF conversion
> (dedicated css, header, footer)?
> My initial though is REST. Is it the right direction? Or are there other
> options?
>
> Thanks for tips, enlightenment or thought on the matter.
>
> Hilaire
>
> --
> Dr. Geo
> http://drgeo.eu
> http://google.com/+DrgeoEu
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


More information about the seaside mailing list