gpt4 book ai didi

jquery - iPAD 上的 PDFJs 模糊 PDF

转载 作者:搜寻专家 更新时间:2023-10-31 08:07:05 25 4
gpt4 key购买 nike

我正在 cordova 应用程序中处理 PDJS View 。

除 pdf 有点模糊外,一切正常。我知道这在某种程度上是因为视网膜显示屏,但我如何更改此设置或如何获得正确的比例?

目前我正在尝试这个

pdfFile.getPage(data.page).then(function (page) {


canvas.width = $('#pdfContainer').width();
var viewport = page.getViewport(canvas.width / (page.getViewport(1).width));
canvas.width = viewport.width;
canvas.height = viewport.height;

var height= $('#pdfContainer').height();



if (canvas.height > height) {
canvas.height = height;
var viewport = page.getViewport(canvas.height / (page.getViewport(1).height));
canvas.width = viewport.width;
canvas.height = viewport.height;
}

var renderContext = {
canvasContext: context,
viewport: viewport
};

page.render(renderContext);
});

最佳答案

我为此所做的首先是停用图像平滑:

canvasContext = canvas.getContext('2d') as CanvasRenderingContext2D;
canvasContext.imageSmoothingEnabled = false;
canvasContext.webkitImageSmoothingEnabled = false;
canvasContext.mozImageSmoothingEnabled = false;
canvasContext.oImageSmoothingEnabled = false;

然后乘以我使用 window.devicePixelRatio 找到的 devicePixelRatio

    if (window.devicePixelRatio > 1) {
var canvasWidth = canvas.width;
var canvasHeight = canvas.height;

canvas.width = canvasWidth * window.devicePixelRatio;
canvas.height = canvasHeight * window.devicePixelRatio;
canvas.style.width = canvasWidth + "px";
canvas.style.height = canvasHeight + "px";

canvasContext.scale(window.devicePixelRatio, window.devicePixelRatio);
}

这也修复了带有 Retina 显示屏的 Macbocks 的模糊效果。

关于jquery - iPAD 上的 PDFJs 模糊 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37861686/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com