Coder Social home page Coder Social logo

wkhtmltopdf-java's Introduction

Java WkHtmlToPdf Wrapper

A Java based wrapper for the wkhtmltopdf command line tool. As the name implies, it uses WebKit to convert HTML documents to PDFs.

This is based on jhonnymertz/java-wkhtmltopdf-wrapper

Requirements

wkhtmltopdf must be installed and working on your system.

Usage

WkHtmlToPdf pdf = new WkHtmlToPdf();

pdf.addSources(Source.from("<html><head><meta charset=\"utf-8\"></head><h1>Müller</h1></html>", "UTF-8"));
pdf.addSources(Source.fromUrl("http://www.google.com"));

// Add a Table of contents
pdf.addToc();

// The `wkhtmltopdf` shell command accepts different types of options such as global, page, headers and footers, and toc. Please see `wkhtmltopdf -H` for a full explanation.
// All options are passed as array, for example:
pdf.addArguments(
	Argument.from(Option.PageOption.EnableJavascript),
	Argument.from(Option.HeaderAndFooterOption.HeaderHtml, "file:///example.html")
);
pdf.addArguments(Option.NoFooterLine.NoFooterLine);

// Save the PDF
pdf.save(Paths.get("output.pdf"));

Maven dependency

<dependencies>
	<dependency>
		<groupId>com.ztomic</groupId>
		<artifactId>wkhtmltopdf-java</artifactId>
		<version>0.0.1</version>
	</dependency>
</dependencies>
<repositories>
	<repository>
		<id>bintray</id>
		<name>bintray</name>
		<url>http://jcenter.bintray.com/</url>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</repository>
</repositories>

wkhtmltopdf-java's People

Contributors

ztomic avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.