When converting long HTML file to PDF, you may meet two kinds situations: one is that long HTML is totally kept in one PDF page, which will be hard to be printed; another situation is that the long HTML file is cut at random paragraph, some time image will be cut into two parts. In order to convert long HTML to PDF perfectly, we can split long HTML file to small parts by specifying height. In the following part, I will show you how to make it.
I use software VeryDOC DOC to Any Converter, which is a command line Window application. It can convert HTML to PDF and specify width and height. After conversion, if you need to set password to output PDF, this software also can make that for you.
Step 1. Download DOC to Any Converter
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can call the executable file in MS Dos Windows. And all the parameters and examples are listed in readme.txt.
- If you need to know more functions of this software, please check them in software homepage.
Step 2. Convert long HTML to PDF and split it by height.
- When run this software, please refer to the usage and examples.
- Usage: DOC2Any [options] <in-file> [<out-file>]
- Here are some examples for your reference.
doc2any.exe C:\in.htm C:\out.pdf
By this command line, we can convert HTML to PDF singly.
doc2any.exe –emfheight 200 C:\in.html C:\out.pdf
By this command line, we can split long HTML at 200
doc2any.exe C:\in.mhtml C:\out.pdf
It can help you convert MHTML file PDF too.
doc2any.exe -ownerpwd 123 -keylen 2 -encryption 3900 C:\in.htm C:\out.pdf
When conversion from HTML to PDF, we can set password to protect output PDF by owner password and open password.
doc2any.exe -viewerzoom 1600 -viewpage 10 -viewpagemode 2 -view "C:\in.htm" C:\out.pdf
After conversion, we can set zoom rate, view page and view page mode.
for %F in (D:\test\*.htm) do "doc2any.exe" "%F" "%~dpnF.pdf"
for /r D:\test %F in (*.htm) do "doc2any.exe" "%F" "%~dpnF.pdf
When you need to do batch conversion, please refer to the above two for modes.
doc2any.exe -wtext "VeryPDF" -wf "Arial" -walign 3 -wh 20 -wbox "0,770,612,792" "C:\in.doc" C:\out.pdf
doc2any.exe -wtext "Watermark %PageNumber% of %PageCount%" "C:\in.doc" C:\out.pdf
This software also allows you to convert HTML to PDF and add watermark in batch.
Now let us check related parameters:
-height <int> : Set page height to PDF file
-emfheight <int> : Split a long HTML file by height
-pageheight <int> : Split a long HTML page by page height, same as -emfheight
-pageh <int> : same as -pageheight
-ph <int> : same as –pageheight
-viewerzoom <string> : Set viewer zoom ratio to Adobe Reader
-openpwd <string> : Set 'open password' to PDF file
-ownerpwd <string> : Set 'owner password' to PDF file
-wtext <string> : Watermark text on printed document
-wtext does support following dynamic values:
%PageCount%, %PageNumber%, %PageCountRoman%, %PageCountRoman2%,
%PageNumberRoman%, %PageNumberRoman2%, %Author%, %Keywords%,
%Subject%, %Title%, %Filename%, %Date%, %Time%
-wtype <int> : type of watermark
0 : normal watermark
1 : watermark on header
2 : watermark on footer
By this software and those parameters, we can handle long HTML file when converting HTML to PDF. During using, if you have any question, please contact us as soon as possible.