viewer.js icon indicating copy to clipboard operation
viewer.js copied to clipboard

Printing the document

Open cray0000 opened this issue 9 years ago • 1 comments

Hello, I managed to print the document page by page by looping through the svg iframe of each page:

// The actual pages' svg iframes start from the 1st one, not from 0th
for(i = 1; i++; i < window.frames.length) {
  window.frames[i].focus();
  window.frames[i].print();
}

This opens print preview for each page separately and you can print each of them just fine. But forcing user to click Print for each page is obviously a very bad UX.

Is it possible to print the whole document?

cray0000 avatar Jun 04 '15 05:06 cray0000

This is not really feasible with viewer.js, because all pages would have to be loaded for printing to work. If you only had very short documents (less than ~16 pages), you could probably wait for all pages to load and then apply a print stylesheet to the html so that only the content you desire (i.e., the pages) is visible. In my experience, this does not work very well.

I would recommend using the content endpoint to serve a PDF that the user can print directly.

lakenen avatar Jun 04 '15 21:06 lakenen