@author Guoguo 2013.11.24
about Flying-saucer-pdf
is a xml/css renderer, the Flying-saucer-pdf tool takes an XML standard file as input, CSS for typesetting, styling, output a Swing Panel, picture, PDF document. Support for XHTML 1.0 (Strict),HTML format, CSS 2.1. When it comes to CSS, pay attention to the difference between screen style and flat media style (that is, print style) .
Flying-saucer-pdf relies on Itext
Application Scenarios
Instantly download PDFs on the web
Limitation Issues
Resource loading and layout is single-threaded.
Support for XHTML than XML + CSS, not all XHTML, HTML tags, such as <object> not supported.
Traditional HTML or "sheet" is not supported.
Support for oscillating printing, but not enough quality. Ask for details on the mailing list.
Incremental layouts are not supported (for on-screen media only).
It cannot be used for user-editable content, and the output is read-only.
HTML plugins such as applets, flash programs, etc. are not supported.
Scripts (such as JavaScript) are not supported.
Dynamic changes to content require reloading the document (fast but obvious), and cannot dynamically change the DOM and view the results.
JavaScript dom Callbacks (Onload,onclick events, etc.) are not supported.
Go to PDF
1. Load fonts, such as bold, Arial, and other Chinese fonts. Other support fonts can be viewed in the Com.lowagie.text.pdf.BaseFont class
Import Com.lowagie.text.pdf.basefont;itextrenderer renderer = new Itextrenderer (); Fontresolver resolver = Renderer.getfontresolver (); Resolver.addfont ( "C:\\winnt\\fonts\\arialuni. TTF ", basefont.identity_h, basefont.not_embedded);
2. For each page size of the PDF, refer to CSS3 print style https://www.w3.org/TR/css3-page/
3. For PDF page margins, header footer, refer to CSS3 plot style https://www.w3.org/TR/css3-page/
4. About PDF Paging
When rendering, FS has default paging.
Of course you need to force paging, you can use
page-break-before
page-break-after
Force is not paged, you can use
Page-break-inside
5. Support Bookmarks\ Pictures
Reference
Official Document: Http://flyingsaucerproject.github.io/flyingsaucer/r8/guide/users-guide-R8.html
about using Flying-saucer-pdf to implement Xhtml2pdf