a) import PDF.js
b) modify the importFile example
c) pass the data to a Pimage
//this is the code I added to the example
PDFJS.getDocument('hellow.pdf').then(function(pdf) {
pdf.getPage(1).then(function(page) {
var scale = 1.5;
var viewport = page.getViewport(scale);
var canvas = document.getElementById('the-canvas');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
var img = new Image();
img.onload = function (event2) {
sketch.newImageAvailable(img);
}
img.src = canvas.toDataURL(); ////Help!!
});
});
few questions.
1)How do you include a .jr file so that PDFJS visible there
I tried to just create a new tap and paste it there
2)
how to make this work:
img.src = canvas.toDataURL();
3) where should I put the pdf to be loaded as a path (I don't need a load dialog)
currently I am putting it in the folder with the html but it is being overwritten each time I press compile. , how can I avoid that?
can I load from another directory ? ( on same machine )
Answers
I am trying to do something like this:
a) import PDF.js b) modify the importFile example c) pass the data to a Pimage
//this is the code I added to the example
few questions.
1)How do you include a .jr file so that PDFJS visible there I tried to just create a new tap and paste it there
2) how to make this work:
3) where should I put the pdf to be loaded as a path (I don't need a load dialog) currently I am putting it in the folder with the html but it is being overwritten each time I press compile. , how can I avoid that?
can I load from another directory ? ( on same machine )
also tried this:
//I assume the pdf is automatically loaded
so the code breaks at PDFJS.get
seems like it is not included properly?