PDF 生成模板编辑器
开源可视化 PDF 生成引擎,支持自定义模板,并提供面向开发者的 API,灵活构建文档生成流程。
内容比较通常用于快速找出不同 PDF 版本之间的变化,适用于文本信息较多的文件。可以比较的内容包括文本、图片等。
// 获取对比文件的文件流。
const documentA = await fetch('https://example.com/documentA.pdf');
const documentABlob = await documentA.blob();
const documentAFile = new File([documentABlob], 'documentA.pdf');
const documentB = await fetch('https://example.com/documentB.pdf');
const documentBBlob = await documentB.blob();
const documentBFile = new File([documentBBlob], 'documentB.pdf');
const oldDocument = await instance.Core.createDocument(documentAFile); // 旧文档。
const newDocument = await instance.Core.createDocument(documentBFile); // 新文档。
// 对比文档内容。
const result = await oldDocument.compareContent(newDocument, {
compareText: true,
compareImages: true,
colors: {
replace: '#93B9FD',
insert: '#C0FFEC',
delete: '#FBBDBF'
}
});
// 获取包含比较结果的文档blob对象的数组。
const res = await Promise.all([result.base, result.other, result.merged].map(async (doc) => new Blob([await doc.getFileData()], { type: 'application/pdf' })));