HTML转化为pdf文件并合并多个pdf文件
转化的需要使用到 Wkhtmltopdf 这个工具.
下面代码的介绍;
首先我们要获取到web页面,然后把web页面转化为pdf文件,之后是合并pdf(采用的是合并文件的二进制),之后就完事了.
/**
* 生成预览的pdf
*
* @param projectId 项目id
*/
private void createViewFile(String projectId, String audtingInfoId) throws IOException {
final String businessType = "audit-enclosure-total";
List<byte[]> files = Lists.newArrayList();
// 获取对应的html页面 并转化为pdf文件
final String fileName = create(projectId);
// 把转为pdf的html的二进制文件存起来
files.add(FileUtils.readFileToByteArray(new File(fileName)));
final List<Attachment> attachments = attachmentService.selectAttachmentBusinessIds(audtingInfoId);
if (attachments != null) {
for (Attachment attachment : attachments) {