Milorad Filipović February 2016

How to mimic HTML layout with pdfmake

I am having a dynamically generated HTML layout which I would like to mimic in a PDF report, but I am having trouble with the columns specification. Assume that the HTML looks like this:

+------------------------------------------------------+
|                                                      |
|                     SECTION 1                        |
|                                                      |
+------------------------+-----------------------------+
|                        |                             |
|       SECTION 2        |         SECTION 3           |
|                        |                             |
+------------------------+-----------------------------+
|                                                      |
|                     SECTION 4                        |
|                                                      |
+---------------+-------------------+------------------+
|               |                   |                  |
|   SECTION 5   |     SECTION 6     |    SECTION 7     |
|               |                   |                  |
+---------------+-------------------+------------------+ 

And the content of the resulting PDF should be arranged the same. Now, since I don't know the actual layout in advance, I am looping section by section and creating a column for every section. At this point, I am able to calculate the width of a column. The problem is, since everything is a column, everything is at the same row, and I would like to make a wrap, so the columns which add to 100% width take a separate row. Is there a way to implement this in makepdf, or should I take a different approach?

Answers


DataHerder February 2016

I use wkhtmltopdf to render PDF's from HTML. If you want something that's really really close to exactly how the HTML will look, then I would most definitely go with wkhtmltopdf.

Post Status

Asked in February 2016
Viewed 2,710 times
Voted 8
Answered 1 times

Search




Leave an answer