我正在考虑使用pdf.js (一个允许在网页中嵌入pdf的开源工具)。没有任何关于如何使用它的文档。
我假设我要做的是制作一个html页面,在头部引用脚本,然后在主体中放入某种类型的函数调用,其中包含文件名和位置的数组。有人能帮我吗?
发布于 2012-02-17 20:54:59
试试谷歌搜索pdf.js documentation
吧
/* create the PDF document */
var doc = new pdf();
doc.text(20, 20, 'hello, I am PDF.');
doc.text(20, 30, 'i was created in the browser using javascript.');
doc.text(20, 40, 'i can also be created from node.js');
/* Optional - set properties on the document */
doc.setProperties({
title: 'A sample document created by pdf.js',
subject: 'PDFs are kinda cool, i guess',
author: 'Marak Squires',
keywords: 'pdf.js, javascript, Marak, Marak Squires',
creator: 'pdf.js'
});
doc.addPage();
doc.setFontSize(22);
doc.text(20, 20, 'This is a title');
doc.setFontSize(16);
doc.text(20, 30, 'This is some normal sized text underneath.');
var fileName = "testFile"+new Date().getSeconds()+".pdf";
var pdfAsDataURI = doc.output('datauri', {"fileName":fileName});
注意:这里提到的"pdf.js“项目是https://github.com/Marak/pdf.js,自从这个答案发布后就被弃用了。@Treffynnon的答案是关于仍然活跃的Mozilla项目(https://github.com/mozilla/pdf.js),这是大多数搜索者都会寻找的。
https://stackoverflow.com/questions/9328551
复制相似问题