I was wondering how the pdf.js library handles the download of a pdf page.
If I execute this code:
var test_pdf = "documents/pdf";
PDFJS.getDocument(test_pdf).then(function(pdf) {
// Using promise to fetch the page
pdf.getPage(1).then(function(page) {
var scale = 1;
var viewport = page.getViewport(scale);
var realwidth = viewport.width;
// Scale all documents to a width of 520px
var newscale = 520/realwidth;
var viewport = page.getViewport(newscale);
//
// Prepare canvas using PDF page dimensions
//
var canvas = document.getElementById('the-canvas{{slide.page}}');
var context = canvas.getContext('2d');
canvas.height = viewport.height;
canvas.width = viewport.width;
//
// Render PDF page into canvas context
//
var renderContext = {
canvasContext: context,
viewport: viewport
};
page.render(renderContext);
});
So here I only display the first page of the PDF but I think the client downloads the whole pdf right?
If this is right, does anybody maybe if it is possible to only download a given page off the pdf file?
What about idea to split pages from pdf document in several files (e.g. by using PDFtk) and later use/load these pages?