我正在尝试使用pdf.js将KineticJS形状添加到现有的 pdf文件中。我遇到的问题是KineticJS创建一个新的画布,不会使用由pdf.js.创建的画布。我已经尝试在KineticJS中引用pdf.js画布,但这不起作用。任何关于如何整合这两者的想法?主要目的是为pdf提供注释。将动力学JS添加到PDF文件
0
A
回答
0
如果你不太深入这个过程,你可以尝试Bytescout生成.pdf,并且还包含一个钩子来将你的canvas图像加载到你的pdf中。
一切都在客户端完成,因此您可以查看/编辑/查看/编辑您心中的内容。
他们在这里:http://bytescout.com/products/developer/pdfgeneratorsdkjs/index.html(顺便说一句,没有推销这里 - 我没有连接以任何方式bytescout!)
下面是从他们的网站的例子显示了一个嵌入式的画布:
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;
}
+0
谢谢。我认为BytescoutPDF的工作原理与JSPDF相似,它根据画布内容创建一个pdf。我其实没有这个问题。问题在于查看现有PDF(使用pdf.js)并使用KineticJS向该PDF添加注释。 – user2200401 2013-03-22 21:00:17
相关问题
- 1. 将文本添加到PDF
- 2. 将文本添加到PDF
- 3. 使用动力学js添加许多点的线
- 4. d3.js将点击动作添加到力布局圈?
- 5. 添加.js文件到MOSS
- 6. 自动将js/css文件添加到离子项目
- 7. 加载json动力学4.3.3
- 8. 使用动力学js更新画布
- 9. 将PDF阅读能力添加到Android应用程序
- 10. 将PDF文档添加到表格
- 11. iTextsharp将语言添加到PDF文档
- 12. 添加密码的PDF文件自动
- 13. 将matplotlib barplot添加到PDF
- 14. 将图添加到Reportlab PDF
- 15. 在Wordpress上添加pdf文件到robots.txt
- 16. 添加绘图到pdf文件
- 17. 在线添加注释到PDF文件
- 18. 将PDF文件附加到邮件中
- 19. 将附件添加到pdf文件并附上链接
- 20. 如何添加文本到力向图中D3.js
- 21. 添加自定义js文件到JHipster
- 22. 保存后自动将pdf文件附加到邮件中
- 23. PDFSharp;将SVG签名添加到PDF文件
- 24. 将PIL图像添加到pdf文件中
- 25. 将固定宽度文件添加到PDF
- 26. iText的 - 将内容添加到现有的PDF文件
- 27. Rails and Prawn PDF - 将当前项目ID添加到文件名?
- 28. 将日期和时间添加到pdf输出文件名
- 29. 使用代码将Pdf文件添加到资源C#
- 30. 将html添加到文件
好吧,这个想法是将Kinetic画布保存为图像,然后将该图像放置在pdf.js画布中。这可能会指向你在正确的方向:http://stackoverflow.com/questions/13164226/kineticjs-toimage-proper-method-for-creating-image-from-region-group – SoluableNonagon 2013-03-22 18:46:26
我不知道这将是有益的。我需要能够稍后编辑形状。我还需要能够看到pdf,以便放置形状很有意义。 – user2200401 2013-03-22 19:45:45
您可以发布引用pdf.js画布的代码 – SoluableNonagon 2013-03-22 20:20:58