我正在使用 PDF.js 框架来呈现 PDF。我正在使用 base64 数据来呈现 PDF。但是在 IE 11 pdf 中看起来很模糊。
请参见 IE 11 的以下屏幕
见下面的代码:
var renderPDF = function(url, canvasContainer,data) {
var scale= 0.9; //"zoom" factor for the PDF
function renderPage(page) {
var canvas = document.createElement('canvas');
var viewport = page.getViewport(scale);
var ctx = canvas.getContext('2d');
var renderContext = {
canvasContext: ctx,
viewport: viewport
};
canvas.height = viewport.height;
canvas.width = viewport.width;
canvasContainer.appendChild(canvas);
page.render(renderContext);
}
function renderPages(pdfDoc) {
for(var num = 1; num <= pdfDoc.numPages; num++)
pdfDoc.getPage(num).then(renderPage);
}
PDFJS.disableWorker = false;
var pdfAsDataUri = "data:application/pdf;base64,"+data; // shortened
var pdfAsArray = convertDataURIToBinary(pdfAsDataUri);
PDFJS.getDocument(pdfAsArray).then(renderPages);
};
var BASE64_MARKER = ';base64,';
var convertDataURIToBinary = function(dataURI) {
var base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
var base64 = dataURI.substring(base64Index);
var raw = atob(base64);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
for(var i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
}
return array;
};
请帮我。