How to insert a page break in HTML so htmltools.exe parses it?

So basically I'm using htmltools.exe to convert a dynamic HTML report to PDF with "-webkit" option.

The report has a particular format and I've been asked to clone that format with HTML.

The problem I'm facing is that I can't simulate a 100% functional page break in html so htmltools.exe can interpret it and send content to another page.

I'm trying to avoid page size measurement methods and so.

TIA for any help provided.

So far I'm emulating page break using <br> and it works. I still have to do some testing though.

Customer
------------------------------

HTML Converter Command Line (htmltools.exe),
https://www.verypdf.com/app/html-converter/try-and-buy.html#cmd

image
Specify a CSS rule specific to the print media type. There are a number of properties that can be used for paging. I find it easiest to attach the page-break-before property to a class, as shown below.

In the HTML:

<p>Page 1, paragraph 1</p>
<p class="new-page">Page 2, paragraph 1</p>
<p>Page 2, paragraph 2</p>

In the CSS:

@media print {
  .new-page {
    page-break-before: always;
  }
}

Or, you can also add following code into your HTML code where you want to break the page,

<div style = "display:block; clear:both; page-break-after:always;"></div>

VeryPDF
------------------------------
Hi,
 
I have a problem with printing the content in new pages. I am adding <div style="page-break-before:always"></div> to my html file to the positions where I want to start to a new page, but it looks like it is only adding some empty space after that. I am sending 2 example files, 1 with page breaks and 1 with no page breaks.
 
I am using this command by the way, if it has anything to do.

htmltools.exe -webkit "-$" "XXXXXXXXXXXXXXX" -javascript-delay 5000 -run-script-file "chart_legend_fix.txt" D:\PDF_Output.html _test_webkit.pdf
 
Thanks in advance.
Customer
---------------------------------------
We suggest you may add following line to your HTML code where you want to break the pages,

<div style = "display:block; clear:both; page-break-after:always;"></div>

If you still can't get it work, please send to us your sample HTML file, we will test it and come back to you asap.

VeryPDF
---------------------------------------
Hi,
 
I added the line you mentioned, but it looks like it is sometimes working and sometimes not working on my example. I am sending the sample html and the output pdf in the attachments.
 
Thanks in advance.
Customer
---------------------------------------
We added following style into the HTML file, the resultant PDF file looked better,

<style type="text/css">
thead {
    display: table-row-group;
}
tr {
    page-break-before: always;
    page-break-after: always;
    page-break-inside: avoid;
}
table {
    word-wrap: break-word;
}
table td {
    word-break: break-all;
}
</style>

You may test the new HTML file to try again.

Because the new CSS code will break the pages automatically, so it's not necessary to force break the pages again, however, if you wish break the pages on the special positions, you may use '<div style = "display:block; clear:both; page-break-after:always;"></div>' code continue, that's no problem.

VeryPDF
---------------------------------------
Hello,

Continue to previous message, '<div style = "display:block; clear:both; page-break-after:always;"></div>' may not work properly if your HTML page contains heavy and complicated tables, this problem is caused by webkit engine, because webkit engine doesn't support '<div style = "display:block; clear:both; page-break-after:always;"></div>' pagination tag very well.

In this cause, we have another solution to you, you may download "HTMLPrint to Any Converter Command Line" from this web page to try,

https://www.verydoc.com/htmlprint-to-any.html

after you download and unzip it to a folder, you may run following command line to convert your HTML file to PDF file properly with pagination,

html2any.exe -marginleft 20 -margintop 20 -marginright 20 -marginbottom 20 -printtopdf "D:\PDF_Output.pdf" "D:\PDF_Output.html"

html2any.exe does use Internet Explorer's engine to render web page with pagination, it works better than webkit engine for pagination in printing function.

Thank you.

Regards.
VeryPDF

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!