Java generates several scenarios for word

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_a5e968370101crtl.html

1. Jacob is the abbreviation for Java-com Bridge, which builds a bridge between Java and Microsoft's COM components. Using Jacob's own DLL dynamic link library, and through the way of JNI implementation of the Java platform on the COM program calls. DLL dynamic-link library generation requires support from the Windows platform.

2. Apache POI includes a series of APIs that can manipulate various format files based on the Microsoft OLE 2 Compound document format, which can be used to read and write files such as Excel, Word, and so on in Java. His Excel processing is very powerful, for word also limited to read, currently can only implement some simple file operation, cannot set style.

3. Java2word is a component (class library) that calls the MS Office Word document in a Java program. The component provides a simple set of interfaces so that the Java program invokes his service to manipulate the Word document.
These services include opening a document, creating a new document, finding text, replacing text, inserting text, inserting a picture, inserting a table, inserting text at a bookmark, inserting a picture, inserting a table, and so on. Populating data into tables reading tabular data, version 1.1 enhanced features: Specify a text style, specify a table style. This way, you can dynamically compose Word documents.

4, itext operation Excel is OK. For a lot of complex word is also a nightmare. The usage is very simple, but the function is very few, cannot set the printing direction and so on.

5, JSP output style is basically not standard, and to print out is even more miserable.

6, it is very simple to do with XML. Word supports XML format from 2003, the general idea is to use office2003 or 2007 to edit the word style, and then save as XML, the XML is translated into a freemarker template, Finally, we use Java to parse the Freemarker template and output doc. A Word document that has been tested in such a way is fully compliant with Office standards, has a convenient style, content control, and does not distort printing, and the resulting document is exactly the same as editing a document in office.

Summary of Java generated PDF scenarios

1. Jasper report generate PDF: The design idea is to make a template, then get the data, and finally integrate the two to get the results. But the problem with the Jasper report is that the way it generates templates is too complex, and even with the help of the IDE, we need to know a lot of the rules, otherwise it will be a great hassle for debugging.

2. OpenOffice Generate Pdf:openoffice is open source software and can run on Windows and Linux platforms.

3. Itext + flying saucer generate pdf:itext and flying saucer are free open source, and platform-independent, combined with CSS and velocity technology, can be very well implemented.

Generally using a third scenario is much more, the steps it implements are very simple.

Java generates word pros and cons comparison

The technology used

Advantages

Disadvantages

Jacob

Powerful features

Large code size, cumbersome to set style, requires Windows platform support, cannot cross platform

Apache POI

Read and write Excel is powerful and easy to operate

Generally only use it to read Word, can create simple word, cannot set style, function too little

Java2word

Powerful and easy to operate

Can meet the general requirements, does not support the 07 format, the Chinese developed, more resources, need to support the Windows platform

IText

Full function, can meet the general requirements

You cannot generate or manipulate DOC documents directly, only RTF-formatted documents, and RTF can also be opened with Word

Jsp

Simple operation and Low code volume

Can export the current page simple word, cannot set style, poor aesthetics, unable to manipulate word

XML (BEST)

Less code, style, content easy to control, print not deformed, fully compliant with Office standards

The Word template needs to be designed in advance, marked with a special mark where it needs to be replaced

Java generate PDF pros and cons comparison

The technology used

Advantages

Disadvantages

OpenOffice

Office software itself, it's easy to design some document templates that support Java calls to convert Word to PDF

Need to install first, Design PDF template style, and then use the program to fill those reserved variables

Itext

To meet the requirements, itself provides some API

Unable to recognize a lot of HTML tags and attribute, do not recognize the CSS, you need to use its API function to set the style

Jasper Report

Can meet the requirements, the use of more than the market, related documents more

Complex, difficult to fully grasp, need to design templates, strong reliance on the IDE for visual editing

Flying Sauser (best)

Can parse HTML and CSS output into image, PDF and other formats, easy to operate, powerful API

Need to write freemarker or velocity templates, create HTML, sketch PDF styles

Java generates several scenarios for word

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.