Hi,
I am new to PDFGenerator, but after looking for quite a while I did not seem to find a question, so I decided to post - and maybe help other people who have the same issue:
How do I a control page breaks when I transform an HTML document to PDF using PDFGenerator's htmlFileToPDF method.
I am trying to use page-break-after - but PDF Generator still creates a single page.
But It could be that this is actually a symptom of a wider problem: We have a nice HTML report, which uses media print in the CSS to create a printable version, which adds page breaks, and headers and footers on the printable page in the browser - How do I tell PDFGenerator, that I want it to render the HTML as media print ?
Here is the minimal HTML make I could come up with, which shows my approach for the page breaks:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<style type="text/css">
.pagebreak{
page-break-after:always;
}
</style>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>
2 page document
</title>
</head>
<body>
<p class="pagebreak">
This is the first page (with p class="pagebreak" )
</p>
<p>
This is the second page
</p>
</body>
</html>
Any suggestions are welcome
Thanks
Thomas
Views
Replies
Total Likes
I did some more trials, and here is where I am at:
As page-break-after:always; was ignored by PDFGenerator, I used a hack: I wrapped my pages inside div's which have the height of the page, and this seems to work. In addition I had to edit my CSS, and remove the @media print wrapper around my print specific CSS parts, to get my print media specific formatting inside HTML to the PDF page.
I do not consider this a solution, but more of a hack - but it might work for what we are doing, and maybe it works for somebody else.
But what I am actually trying to do is the following:
We have a systems which creates reports in HTML which can be viewed in a browser, and printed from the browser, now we try to use PDFGenerator, to generate reports in PDF, with a minimal effort ( I know this is a the wrong way arround, HTML is not a language targeted at creating printable reports, but that's what we are doing now, and I think many other people are in the same boat)
Still if anybody has a better solution, please chime in, or tell me why the hack I did is a real bad idea - any feedback is welcome
Thomas
Views
Replies
Total Likes