How to make PDF with turning page ability?

2019-08-05 05:32发布

问题:

In one of the weirdest client's requirement we need to devlop a functionality to generate a pdf document from java program(i did it with iText). But the view of pdf is problem. The client wants pdf generated in such a way that, it should have functionality of turning the page like we do in html using css. The book view of the pdf. I know this is weird and can't be done as we need to change the functionality of Adobe Reader itself. Kindly let me know it it is possible if yes then HOW

回答1:

I'm not sure what the customer expects, but what he can get entirely depends on the PDF viewer that is being used and the functionality described in the PDF specification (ISO-32000-1). The feature that is closest to page turning is called "page transition". It is similar to what you can achieve in PowerPoint when going from one page to the other (box in, box out, dissolve,...). See the MovieSlideShow example for some code.

The only correct answer to this question is: use a PDF viewer that support page turning. For instance: I think that the guys from IDR Solutions have a JavaFx-based viewer that turns pages as if you're reading a book. Of course: in this case all consumers of the PDFs should use the same viewer (and that may not be an option).



回答2:

The way this is done is by using rotate and translate3D in CSS. You can for example create a page turn effect using the following style:

position: absolute; top: 64px; left: 554px; overflow: hidden; z-index: 125; width: 465px; height: 465px; -webkit-transform-origin: 0% 0%; -webkit-transform: translate3d(0px, 0px, 0px) rotate(49.90581454908315deg); display: block;

The effect if applied will look like this:

The rest is about animating these style settings when the mouse is hovering the document etc. You can see the example I took the screenshot from on the following url: http://devaldi.com/zine/NZ_Tourism_2007.php?ro=html5,flash



标签: java pdf itext