Print to PDF (client side)
klokan opened this issue · comments
Similar to:
http://gingerik.github.io/ol3/examples/export-pdf.html
But - it renders to external (invisible canvas).
Clean code in a branch of iiifviewer.
Print the visible bounds so it fits to page.
It should run with IIIF but also other sources (first version can always expect pixel coordinates.
Ideal - title / url / copyright notice / logo overlay in corners.
First version: http://dev.djanak.cz/iiif/
FROM:nls
Dalibor / Klokan,
Thank you for your work and forwardings on this.
I just wanted to clarify that I think your http://klokantech.github.io/iiifviewer/ is very close to our 'Print Screen' requirements. If I print in a Landscape orientation, it looks fine, but in portrait it squashes the aspect ratio - but maybe this is my print settings? Apart from this, it is simple and effective - we just want an easy way of printing in a web browser as our current OL2 viewer at: http://maps.nls.uk/view/00000207 doesn't allow easy printing - we need users to do a screen capture.
I just don't know if we really need all the options on size and orientation to generate a PDF at: http://dev.djanak.cz/iiif/ A few people will like this, but others may find it more complicated?
I'm happy to be guided by you, but just wanted to clarify our general requirements.
In the final application I expect to have always only a single print button and nothing more.
For the development it is good to have the options.
This approach for printing will run only with OL3 viewer and browsers which supports it - so an upgrade to IIIF viewer is required in NLS - soon or later.
The sample viewer must be fullscreen.
We still need to explore possibility to load higher resolution (DPI) content from the server and detect whether the default A4 should be landscape or potrait based on the size of the window. On tablets, for example, it may be more practical to have portrait printing by default.
The page must always contain what is visible on screen and something extra to fill the paper completely.
FROM:C.Fleet@nls.uk
Great, many thanks for explaining all this - this makes complete sense. I hadn't thought about these things, and its fine and sensible to develop with these options.
Results of internal discussion on this subject:
- The code to be pushed to a "pdf" branch of iiifviewer repository (open-source)
- The sample demo all should be in gh-pages with:
- fullscreen mode
- single "Print" button
- autodetection of landscape vs potrait and always print to A4
- logo of IIIF viewer on white transparent border in top left (to be replace lated on by institution logo)
- URL of the page printed our on transparent rectangle - aligned to the left bottom.
There are limits of this implementation. Higher DPI and better clipping is very problematic, image server must support CORS headers (IIIFServer does), there may be performance issues for large screens (according testing) and on this function will run only on modern browsers.
Let's finish this implementation now to close it. All issues above, including possible support for existing OL2 viewer in NLS may be addressed with server side print to PDF - new ticket https://github.com/klokan/gr4/issues/118
Done in pdf branche. Last changes:
- auto detect size of document (not in example but works well)
- elements can be added from another side using negative values of position
- merge changes from master
Example at http://klokantech.github.io/iiifviewer/examples/print.html
@klokan please review and close.
Finally jsPDF doesn't support transparency colors. But rest are implemented and showed in examples.
Reported by NLS as not functioning in IE (9-11):
FROM:C.Fleet@nls.uk
Hello Dalibor,
Well, I know you thought this was done, but we have just have one query/problem which I hope will be quick to resolve. The printDoc() function generates a security error and no PDF in all the versions of Internet Explorer (versions 9-11) we have tried here. It works fine in Chrome and Firefox, but please can it be fixed so it works in IE?
Many thanks,
Chris
Possible workaround with Downloadify for IE.
FROM:nls
Petr / Dalibor,
Thank you for re-opening this. I didn't realise when I asked yesterday, that the PDF download is actually working okay in IE for your original implementation - ie. http://geo.nls.uk/maps/dev/iiifviewer/index.html - but just not with the NLS CSS, ie
http://labs.klokantech.com/nls/iiifviewer/iiifviewer.html
The bug for IE print is probably related to CSS. We are examining...
I tested IE9 and I am getting security error on getImageData even on the example http://klokantech.github.io/iiifviewer/examples/print.html - but this may be related to implementation of the CANVAS in IE9.
IE 11 runs fine.
We are back in the fact, that only reliable and always running print implementation without limits is to be done on the server: https://github.com/klokan/gr4/issues/118