An open API service indexing awesome lists of open source software.

https://github.com/vdaburon/convert-html-to-pdf

Convert a simple HTML page to PDF document
https://github.com/vdaburon/convert-html-to-pdf

convertor html html-converter pdf tool

Last synced: 3 months ago
JSON representation

Convert a simple HTML page to PDF document

Awesome Lists containing this project

README

          

# convert-html-to-pdf
Convert a simple HTML page to PDF document

[![Maven Central](https://img.shields.io/maven-central/v/io.github.vdaburon/convert-html-to-pdf)](https://central.sonatype.com/artifact/io.github.vdaburon/convert-html-to-pdf)
![Free](https://img.shields.io/badge/free-open--source-green.svg)

Project at GitHub : https://github.com/vdaburon/convert-html-to-pdf

## Example
Convert a HTML page to a PDF document, set the image width.

Parameters :
- html_in the html page to read
- pdf_out the pdf document to generate
- (optional) image_width the image width in the html page

Launch of the conversion:

java -jar convert-html-to-pdf-1.0-jar-with-dependencies.jar -html_in index.html -pdf_out report.pdf -image_width 960

Notes:
- The directory where the HTML file is set must be writable to create a temporary XHTML file inside
- Need a JDK/JRE 1.8 or more

![Diagram Convert HTML to PDF](doc/images/diagram_convert_html_to_pdf.png)

## License
See the GNU Lesser General Public License (LGPL), version 3

[https://www.gnu.org/licenses/lgpl-3.0.html](https://www.gnu.org/licenses/lgpl-3.0.html)

Because library com.openhtmltopdf use this license

## Ready to use
In the [Release of the project](https://github.com/vdaburon/convert-html-to-pdf/releases) you will find the tool compiled in one (uber) jar file which is directly usable.

## Help


usage: io.github.vdaburon.converthtml2pdf.Html2PDFConvertor [-help] -html_in <html_in> [-image_width <image_width>]
-pdf_out <pdf_out>
io.github.vdaburon.converthtml2pdf.Html2PDFConvertor
-help Help and show parameters
-html_in <html_in> Html file to read (e.g: index.html)
-image_width <image_width> Optional, Image width in pixels referenced by the html page (e.g:960)
-pdf_out <pdf_out> PDF file generated (e.g: report.pdf)
E.g : java -jar convert-html-to-pdf-<version>-jar-with-dependencies.jar -html_in index.html -pdf_out report.pdf
-image_width 960

## Usage Maven

The maven groupId, artifactId and version, this plugin is in the **Maven Central Repository** [![Maven Central](https://img.shields.io/maven-central/v/io.github.vdaburon/convert-html-to-pdf)](https://central.sonatype.com/artifact/io.github.vdaburon/convert-html-to-pdf)

```xml
io.github.vdaburon
convert-html-to-pdf
1.0
```
Just include the plugin in your `pom.xml` and execute `mvn verify`

or individual launch `mvn -Dimage_width=960 -Dhtml_in=target/index.html -Dpdf_out=target/report.pdf exec:java@convert_html_to_pdf`

```xml


index.html
document.pdf
1024



io.github.vdaburon
convert-html-to-pdf
1.0






org.codehaus.mojo
exec-maven-plugin
1.2.1



convert_html_to_pdf
verify

java


io.github.vdaburon.converthtml2pdf.Html2PDFConvertor

-html_in
${html_in}
-pdf_out
${pdf_out}
-image_width
${image_width}






```

## Link to others projects
Usually this plugin is use with [jmeter-graph-tool-maven-plugin](https://github.com/vdaburon/jmeter-graph-tool-maven-plugin)

and this plugin [create-html-for-files-in-directory](https://github.com/vdaburon/CreateHtmlForFilesInDirectory)
1) The **jmeter-graph-tool-maven-plugin** create the report csv files and graphs
2) The **csv-report-to-html** create the **html table report** from the csv file
3) The **create-html-for-files-in-directory** create a page html this links to images and files in a directory to show and add links

## Versions
2025-09-25, Version 1.0