I am using HtmlTools.exe command line to convert a .html file to a .pdf. The .html file has multiple tags in it and I was wondering if there is a way to page break at the body tags?
The command line I am currently using is:
htmltools.exe -html2pdf2 -width 612 -height 792 -emfheight 792 -nocenter "C:\TestReceipt.html" "C:\TestReceipt.pdf"
========================================================
htmltools.exe does support following two options,
-breakpagebytext <string> : Split a long HTML page by a special string.
-delbreakpagetext : Delete string of -breakpagebytext from output PDF file, this option is only work when -playemf2 parameter used.
you can use these options to break a long HTML file to multipage PDF file with special text line, for example, you can put following contents to a HTML file, e.g., D:\test.html file,
-------------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Page test</title>
</head>
<body>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #1</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #2</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #3</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #4</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #5</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #6</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #7</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #8</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #9</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #10</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #12</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #13</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #14</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #15</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><b><font face="Verdana" color="#FF0000">Break page at here #16</font></b></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
<p><font face="Verdana">Page test...</font></p>
</body>
</html>
-------------------------------------------------------
In this test HTML file, the "Break page at here" text line is the break symbol, you can insert it to the place where you want to break following contents to a new page, after that, you can run following command line to convert the long HTML file to multi-page PDF file, htmltools.exe will search "Break page at here" page breaker and break the PDF pages automatically,
htmltools.exe -nocenter -playemf2 -width 612 -height 792 -breakpagebytext "Break page at here" "D:\test.htm" "D:\test_keep_breakpagetext.pdf"
htmltools.exe -nocenter -playemf2 -width 612 -height 792 -delbreakpagetext -breakpagebytext "Break page at here" "D:\test.htm" "D:\test_delete_breakpagetext.pdf"
You can also use -html2pdf2 and -webkit parameters to convert a long HTML file to multi-page PDF file automatically, but -html2pdf2 and -webkit parameters will control the page breakers automatically, you can not break the pages at special position, if you don't want to control the page breaks by yourself, these options will useful to you,
htmltools.exe -html2pdf2 -width 612 -height 792 -emfheight 792 -nocenter "C:\TestReceipt.html" "C:\TestReceipt.pdf"
htmltools.exe -webkit "D:\test.htm" "D:\test_webkit.pdf"
The following is the third solution to control the page breaker during HTML to PDF conversion, you can run following command line to convert your long HTML file to multipage PDF file easily,
htmltools.exe -nocenter -width 612 -height 792 -emfheight 792 "https://www.verypdf.com/" "C:\multipage.pdf"
You can use "-width" and "-height" parameters to set the paper size for output PDF file, you can also use "-emfheight" parameter to break a long html page into multipage PDF file.
The unit of "-width" and "-height" parameters is POINT, if you wish to use INCH unit, you may convert from inch to point by following expression,
8.5inch = 8.5x72 = 612pt
11inch = 11x72 = 792pt
If you wish call htmltools.exe from your ASP, ASP.NET, PHP, C#, .NET etc. web program languages, you can use EXEShell COM Library (freeware) to call htmltools.exe application, the EXEShell COM Library can be downloaded from following page,
http://www.verydoc.com/exeshell.html
EXEShell COM Library is a freeware, you can use it free.
The last thing, because htmltools.exe is using IE engine to render HTML page to PDF file directly, it is not support Flash, Java, etc. elements in HTML page, if you wish convert these elements into PDF file too, you may choose our other HTML to PDF Conversion products, please look at following page for more information,
https://www.verypdf.com/pdfcamp/convert-html-to-pdf.html