我正在创建图像并将其保存为pdf:
printDocument: props => () => {
const input = document.getElementById(`${props.id}`);
const pdf = new jsPDF({
orientation: "p",
unit: "mm",
format: "a4"
});
html2canvas(input).then(canvas => {
const fullQuality = canvas.toDataURL("image/jpeg", 1.0);
pdf.addImage(fullQuality, 0, 0);
pdf.save("download.pdf");
});
}
根据文档- reference
const fullQuality = canvas.toDataURL("image/jpeg", 1.0)
这是高质量的图像,但是在pdf中,我实际上可以看到像素