Install OpenOffice.org
I installed 3.3 successfully.
Java code
- Package com. chinacreator. test;
- Import java. Io. file;
- Import java.net. connectexception;
- Import java. util. date;
- Import com. artofsolving. jodconverter. documentconverter;
- Import com. artofsolving. jodconverter. OpenOffice. Connection. openofficeconnection;
- Import com. artofsolving. jodconverter. OpenOffice. Connection. socketopenofficeconnection;
- Import com. artofsolving. jodconverter. OpenOffice. converter. openofficedocumentconverter;
- Import java. Io. bufferedreader;
- Import java. Io. ioexception;
- Import java. Io. inputstream;
- Import java. Io. inputstreamreader;
- Import java. util. List;
- Public class jod4doctopdf {
- Public void doctopdf (File inputfile, file outputfile ){
- Date start = new date ();
- // Connect to an OpenOffice.org instance running on port 8100
- Openofficeconnection connection = new socketopenofficeconnection (8100 );
- Try {
- Connection. Connect ();
- // Convert
- Documentconverter converter = new openofficedocumentconverter (connection );
- Converter. Convert (inputfile, outputfile );
- } Catch (connectexception cex ){
- Cex. printstacktrace ();
- } Finally {
- // Close the connection
- If (connection! = NULL ){
- Connection. Disconnect ();
- Connection = NULL;
- }
- }
- Long L = (start. gettime ()-New Date (). gettime ());
- Long day = L/(24x60*60*1000 );
- Long hour = (L/(60x60*1000)-day * 24 );
- Long min = (L/(60*1000)-day * 24*60-hour * 60 );
- Long S = (L/1000-day * 24*60*60-hour * 60*60-min * 60 );
- System. Out. println ("generated" + outputfile. getname () + "consumed:" + min + "min" + S + "Sec ");
- }
- Class testthread extends java. Lang. Thread {
- Public file inputfile;
- Public file outputfile;
- Public void run (){
- Jod4doctopdf T = new jod4doctopdf ();
- T.doc topdf (inputfile, outputfile );
- System. Out. println (outputfile. getname () + "file generated ");
- }
- }
- Public void test (string path, string st ){
- Testthread T1 = new testthread ();
- T1.inputfile = new file (path + st + ". Doc ");
- // T1.inputfile = new file (path + st + ". xls ");
- T1.outputfile = new file (path + st + ". pdf ");
- //
- // Testthread t2 = new testthread ();
- // T2.inputfile = new file ("D:/document2.doc ");
- // T2.outputfile = new file ("D:/document2.pdf ");
- //
- // Testthread T3 = new testthread ();
- // T3.inputfile = new file ("D:/document3.doc ");
- // T3.outputfile = new file ("D:/document3.pdf ");
- // T2.start ();
- T1.start ();
- // T3.start ();
- }
- Public static void main (string [] ARGs) throws exception {
- String Path = "d :\\"; // path of the converted file
- String STR = "China 2 S"; // name of the converted file
- Try {
- Jod4doctopdf P = new jod4doctopdf (); // generate a PDF
- P. Test (path, STR );
- } Catch (exception ex)
- {
- System. Out. println ("error ");
- }
- System. Out. println ("success ");
- }
- }
Add:
Basically, any OpenOffice document can be opened. Supports XML, Microsoft doc, Excel, pptfile, and other formats.
After OpenOffice is opened, it can be exported as PDF, which can basically meet the requirements of LZ.
1. Install OpenOffice 3
2. Run the following command to start the OpenOffice service:
Cd c: \ Program Files \ OpenOffice.org 3 \ Program
Soffice-Headless-accept = "socket, host = 127.0.0.1, Port = 8100; URP;"-nofirststartwizard
Add: Basically, any OpenOffice document can be opened. Supports XML, Microsoft doc, Excel, pptfile, and other formats. After OpenOffice is opened, it can be exported as PDF, which can basically meet the requirements of LZ.1. Install OpenOffice 3 2. Run the following command to start the OpenOffice service: Cd c: \ Program Files \ OpenOffice.org 3 \ Program Soffice-Headless-accept = "socket, host = 127.0.0.1, Port = 8100; URP;"-nofirststartwizard
|
Add:
Basically, any OpenOffice document can be opened. Supports XML, Microsoft doc, Excel, pptfile, and other formats.
After OpenOffice is opened, it can be exported as PDF, which can basically meet the requirements of LZ.
1. Install OpenOffice 3
2. Run the following command to start the OpenOffice service:
Cd c: \ Program Files \ OpenOffice.org 3 \ Program
Soffice-Headless-accept = "socket, host = 127.0.0.1, Port = 8100; URP;"-nofirststartwizard