HTMLJMerge

Return to Medge's Home Page
This project is hosted at Source Forge SourceForge.net Logo
To download latest HTMLJMerge-1.2.4-27122025.jar. Download HTMLJMerge

HTMLJMerge Icon HTMLJMerge

This HTMLJMerge application allows you to do a mail merge with HTML files. It started because someone asked me to merge using OOJMerge* HTML tags to merge.
It supports the generation of barcodes and QR codes.
QR code support thanks to the great work of Nayuki, a magical girl software developer in Toronto Canada. I much appreciate, not only the incredibly clean code, but the license she released is under (MIT). See https://www.nayuki.io/ for her other stuff.


Examples how to use HTMLJMerge

I've installed wkhtmltopdf to assist in merging to pdf.
The command line would look something like :
java -jar HTMLJMerge.jar -f examples/test_all.html -t examples/results/test_all_res.html -d examples/data_sep.xml -p wkhtmltopdf -s "-q $H $P" -v
      

Full Usage

Usage: java -jar HTMLJMerge.jar -f fromFileName [-t toFileName] -d dataFileName [-p htmltopdf.binary [-s "$H $P"]] [-v] [-q]
where:
  -f fromFileName is the template file.
  -t toFileName is the result file - optional. Creates a default named file if missing.
  -d dataFileName is the data xml file.
  -p htmltopdf.binary binary to convert html to pdf - optional.
  -s "pdf file syntax" the command line syntax template - optional (in quotes $H = the To HTML, $P The PDF).
  -r the size of the buffer to read in files (html and images) - optional defaults to 100k.
  -q quiet mode IE no command line output (file names).
  -v verbose mode IE command line output includes to pdf output.
  
Converting to PDF:
  -p is the binary that will be doing the conversion.
  -s is the command line syntax where $H means the HTML file and $P The PDF.
You do not change $H and $P to your file names you use values $H and $P.
    The command line syntax uses:
    the literal $H and changes that to the actual html file/s internally and
    the literal $P and changes that to the actual pdf file/s internally.
      

Some more examples

For example, to merge from File_F.html using data file File_D.xml:
java -jar HTMLJMerge.jar -f File_F.html -d File_D.xml
      

This will produce File_F_20250808_190606_1.html The date format is yyyyMMdd_HHmmss_I where I is an index to ensure files are not overriden if you are creating more than one per second.

For example, to merge from File_F.html to File_T.htmlusing data file File_D.xml:

java -jar HTMLJMerge.jar -f File_F.html -t File_T.html -d File_D.xml
      
This will produce File_T.html


Future

I'll keep adding stuff to the library as it occurs to me or anyone using this library.

As of Fri 26 Dec 2025 19:46:46 ACDT
HTMLJMerge has 31 classes; containing 6154 lines of which 5742 are not blank

*I have abandoned OOJMerge as the XML inside keeps changing and, although it does check to ensure good XML, sometimes the formatting fails.

Medge's Home Page

Viewed times.