1 Star 0 Fork 0

云剑 / wkhtmltopdf4j

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

WhtmlToPDF java binding

摘要

这个是WkHtmltoPDF的wrapper,本wrapper通过java的jni技术编写, 不需要使用命令行,不需要额外的安装。

使用之前,请首先clone 我的StandAlone工程组, 并且在本地的maven中安装libloader工程。

下面是加载本地类库以及Wrapper的使用的例子。

English

this is a wrapper of WhtmlToPDF native library with java jni.

we can use this library to convert any html file to a pdf.

by the time you need it , clone my standlongs project first, install the libloader to your native maven repository

this is a test code to show how can you use it:

public class Test {

	public static void main(String[] args) {

	    // Load Narive libs
		PlatformLoader loader = new PlatformLoader();
		loader.load(new File("dist/WKHtmlPDF.xml"));

		// converter is available now
		WKHtmlPDFConverter conv = new WKHtmlPDFConverter();
		// you can put logger here
		conv.setOnProgress(i -> {
			System.err.println("Progress is " + i);
		});
		conv.setOnMesssage(e -> {
			System.err.println("Message : " + e);;
		});
		conv.convert(new File("test.html"), new File("test.pdf"));
		conv.convert("<h1>Hello</h1>", new File("Demo.pdf"));
	}
	
}

如何构建

native类库位于binary内部,如果需要从源码构建,请按照如下方法进行:

Mac OS

安装XCode,以及make,gcc,g++等编译器。

进入binary/MacOS文件夹,执行如下命令。

make -f Makefile library

windows

首先安装MinGW 64,然后将MinGW的bin目录放在系统的环境变量Path中。

进入binary/windows文件夹,执行make.bat

./make

How to build

native c++ source code in the binary folder。

Mac OS

open the native/Mac OS,and run the makefile :

make -f Makefile library

windows

open the native/windows and run make.bat

make

局限

本组件只能单线程转换PDF,一个一个的被HTML或者String的执行转换,不能多线程同时操作,因此效率比较有限, 这是因为Qt的渲染只能在Qt的ApplicationThread运行。

由于使用了线程池,所以在关闭应用的时候需要显式的使用System.exit,或者 调用WKHtmlPDFConverter.close

limitation

the wrapper working on a single thread,because render operation must be call on Qt Application thread。

thread pool used in WKHtmlPDFConverter, please call System.exit, or WKHtmlPDFConverter.close when you want to exit the application

空文件

简介

WKHTMLtoPDF的jni形式的Wrapper 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/SWDCloud/wkhtmltopdf4j.git
git@gitee.com:SWDCloud/wkhtmltopdf4j.git
SWDCloud
wkhtmltopdf4j
wkhtmltopdf4j
master

搜索帮助