Several methods of generating word and pdf in java

quote
1. Jacob is the abbreviation of 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 to realize the call to the COM program on the Java platform. The generation of the DLL dynamic link library requires the support of the windows platform.



2. Apache POI includes a series of APIs, which can operate various format files based on MicroSoft OLE 2 Compound Document Format, and can read and write Excel, Word and other files in Java through these APIs. His excel processing is very powerful. For word, it is still limited to reading. Currently, only some simple file operations can be implemented, and styles cannot be set.



3. Java2word is a component (class library) that calls MS Office Word documents in java programs. This component provides a set of simple interfaces, so that the java program can call its service to operate the Word document.
These services include: opening a document, creating a new document, finding text, replacing text, inserting text, inserting pictures, inserting tables, inserting text at bookmarks, inserting pictures, inserting tables, etc. Fill data into the table to read the table data, the enhanced function of version 1.1: specify the text style, specify the table style. In this way, the word document can be typeset dynamically.



4. iText works fine with Excel. It is also a nightmare for complex and large numbers of words. The usage is very simple, but the functions are few, and the printing orientation cannot be set.



5. The JSP output style is basically substandard, and it is even more appalling to print it out.



6. It is very simple to do with XML. Word has supported the XML format since 2003. The general idea is to edit the style of the word with office2003 or 2007, then save it as xml, translate the xml into a FreeMarker template, and finally use java to parse the FreeMarker template and output Doc. After testing, the word document generated in this way fully conforms to the office standard, the style and content control are very convenient, and the printing will not be deformed. The generated document is exactly the same as the edited document in the office.

Summary of java generation pdf scheme

1. Jasper Report generates pdf: The design idea is to generate the template first, then get the data, and finally integrate the two to get the result. But the problem with Jasper Report is that the way it generates templates is too complicated. Even with the help of IDE, we still need to understand many of the rules, otherwise it will bring great trouble to debugging.

2. Openoffice generates pdf: openoffice is open source software and can run on windows and linux platforms.

3. Itext + flying saucer generates pdf: both itext and flying saucer are free and open source, and have nothing to do with the platform. Combined with CSS and velocity technology, they can be well implemented.



Generally, the third scheme is used more, and the steps of its realization are very simple.

JAVA generates word advantages and disadvantages comparison



JAVA generates pdf advantages and disadvantages comparison



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326570137&siteId=291194637