about using Flying-saucer-pdf to implement Xhtml2pdf

Source: Internet
Author: User

@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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.