Answer the question
In order to leave comments, you need to log in
Converting canvas to img object is an empty picture, why?
Hi all.
Doing a PDF download and a preview of the file. Next, you need to save the review as a picture on the server, and before sending it to the server, I decided to see if everything is ok ...
I read PDF, I make canvas - super.
var img = new Image();
img.src = canvas.toDataURL();
document.body.appendChild(img);
Answer the question
In order to leave comments, you need to log in
Wait for page.render to render the pdf on the canvas, after that you can use canvas.toDataURL.
const renderTask = page.render(renderContext).promise;
renderTask.then(() => {
var img = new Image();
img.src = canvas.toDataURL();
img.onload = () => document.body.appendChild(img);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question