Jquery pdfjs到img/canvas,仅适用于FireFox
我使用pdf.js库从客户端的pdf页面制作图像/画布。但它只能在FireFox上运行,不能在Chrome或IE10+上运行。我环顾四周,但找不到好的答案或解决办法 我读到IE或Chrome上的pdf.js需要一个web服务器,但当我在JSFIDLE上尝试代码时,它仍然不起作用 以下是一个例子:Jquery pdfjs到img/canvas,仅适用于FireFox,jquery,image,pdf,html5-canvas,pdfjs,Jquery,Image,Pdf,Html5 Canvas,Pdfjs,我使用pdf.js库从客户端的pdf页面制作图像/画布。但它只能在FireFox上运行,不能在Chrome或IE10+上运行。我环顾四周,但找不到好的答案或解决办法 我读到IE或Chrome上的pdf.js需要一个web服务器,但当我在JSFIDLE上尝试代码时,它仍然不起作用 以下是一个例子: var url='1〕https://raw.githubusercontent.com/mozilla/pdf.js/master/examples/helloworld/helloworld.pd
var url='1〕https://raw.githubusercontent.com/mozilla/pdf.js/master/examples/helloworld/helloworld.pdf';
PDFJS.disableWorker=true;
getDocument(url).then(函数getPdfHelloWorld(pdf){
然后(函数getPageHelloWorld(第页){
var标度=1.5;
var viewport=page.getViewport(比例);
var canvas=document.getElementById('the-canvas');
var context=canvas.getContext('2d');
canvas.height=viewport.height;
canvas.width=viewport.width;
render({canvasContext:context,viewport:viewport})
});
});代码>
似乎GitHub在返回包含内容类型:text/plain的原始文件时添加了标题X-Content-Type-Options:nosniff
。见相关问题:
如相关问题中所述,解决方案是替换https://raw.githubusercontent.com
与https://rawgit.com/
返回内容类型正确的文件
这里更新了fiddle:似乎GitHub在返回包含内容类型:text/plain的原始文件时添加了标题X-Content-Type-Options:nosniff
。见相关问题:
如相关问题中所述,解决方案是替换https://raw.githubusercontent.com
与https://rawgit.com/
返回内容类型正确的文件
这里是最新的小提琴: