Html 将动态JS添加到PDF文件
我正在尝试使用pdf.js将KineticJS形状添加到现有的pdf文件中。我的问题是KineticJS创建了一个新画布,而不会使用pdf.js创建的画布。我曾尝试在KineticJS中引用pdf.js画布,但这不起作用。关于如何将两者结合起来有什么想法吗?主要目的是为pdf提供注释 如果您还不太了解这个过程,您可以尝试使用Bytescout,它可以生成.pdf,还包括一个钩子,用于将画布图像加载到pdf中 一切都是在客户端完成的,因此您可以查看/编辑/查看/编辑您的内容 他们在这里:(顺便说一句,这里没有销售宣传——我与bytescout没有任何联系!) 下面是他们网站上显示嵌入式画布的示例:Html 将动态JS添加到PDF文件,html,kineticjs,pdf.js,Html,Kineticjs,Pdf.js,我正在尝试使用pdf.js将KineticJS形状添加到现有的pdf文件中。我的问题是KineticJS创建了一个新画布,而不会使用pdf.js创建的画布。我曾尝试在KineticJS中引用pdf.js画布,但这不起作用。关于如何将两者结合起来有什么想法吗?主要目的是为pdf提供注释 如果您还不太了解这个过程,您可以尝试使用Bytescout,它可以生成.pdf,还包括一个钩子,用于将画布图像加载到pdf中 一切都是在客户端完成的,因此您可以查看/编辑/查看/编辑您的内容 他们在这里:(顺便说一
function CreatePDF() {
// create BytescoutPDF object instance
var pdf = new BytescoutPDF();
// set document properties: Title, subject, keywords, author name and creator name
pdf.propertiesSet("Sample document title", "Sample subject", "keyword1, keyword 2, keyword3", "Document Author Name", "Document Creator Name");
// set page size
pdf.pageSetSize(BytescoutPDF.A4);
// set page orientation (BytescoutPDF.PORTRAIT = portrait, BytescoutPDF.LANDSCAPE = landscape)
pdf.pageSetOrientation(BytescoutPDF.PORTRAIT);
// add new page
pdf.pageAdd();
// create temporary canvas (you can also simply get existing canvas)
var canvas = document.createElement('canvas');
// set width and height
canvas.width = 320;
canvas.height = 240;
// get context from canvas (to draw on)
var context = canvas.getContext("2d");
// set white background color
context.fillStyle = "#FFFFFF";
// and fill the background with white color
context.fillRect(0, 0, 320, 240);
// draw the yellow circle
context.strokeStyle = "#000000";
context.fillStyle = "#FFFF00";
context.beginPath();
context.arc(100, 100, 50, 0, Math.PI * 2, true);
context.closePath();
context.stroke();
context.fill();
// load image from canvas into BytescoutPDF
pdf.imageLoadFromCanvas(canvas);
// place this image at given X, Y coordinates on the page
pdf.imagePlace(20, 40);
// return BytescoutPDF object instance
return pdf;
}
这个想法是将动态画布保存为图像,然后将该图像放置在pdf.js画布中。这可能为你指明了正确的方向:我不确定这是否有用。我需要能够编辑以后的形状。我还需要能够看到pdf,这样形状的位置才有意义。你能发布引用pdf的代码吗。我认为BytescoutPDF的工作原理类似于JSPDF,因为它从画布内容创建pdf。我其实没有这个问题。问题在于查看现有PDF(带有PDF.js)并使用KineticJS.check-out向该PDF添加注释