OpenOffice + 00002swf + flexpaper (similar to Baidu Library): convert office to PDF (Linux, window)

Source: Internet
Author: User

Install OpenOffice.org

I installed 3.3 successfully.

Java code
  1. Package com. chinacreator. test;
  2. Import java. Io. file;
  3. Import java.net. connectexception;
  4. Import java. util. date;
  5. Import com. artofsolving. jodconverter. documentconverter;
  6. Import com. artofsolving. jodconverter. OpenOffice. Connection. openofficeconnection;
  7. Import com. artofsolving. jodconverter. OpenOffice. Connection. socketopenofficeconnection;
  8. Import com. artofsolving. jodconverter. OpenOffice. converter. openofficedocumentconverter;
  9. Import java. Io. bufferedreader;
  10. Import java. Io. ioexception;
  11. Import java. Io. inputstream;
  12. Import java. Io. inputstreamreader;
  13. Import java. util. List;
  14. Public class jod4doctopdf {
  15. Public void doctopdf (File inputfile, file outputfile ){
  16. Date start = new date ();
  17. // Connect to an OpenOffice.org instance running on port 8100
  18. Openofficeconnection connection = new socketopenofficeconnection (8100 );
  19. Try {
  20. Connection. Connect ();
  21. // Convert
  22. Documentconverter converter = new openofficedocumentconverter (connection );
  23. Converter. Convert (inputfile, outputfile );
  24. } Catch (connectexception cex ){
  25. Cex. printstacktrace ();
  26. } Finally {
  27. // Close the connection
  28. If (connection! = NULL ){
  29. Connection. Disconnect ();
  30. Connection = NULL;
  31. }
  32. }
  33. Long L = (start. gettime ()-New Date (). gettime ());
  34. Long day = L/(24x60*60*1000 );
  35. Long hour = (L/(60x60*1000)-day * 24 );
  36. Long min = (L/(60*1000)-day * 24*60-hour * 60 );
  37. Long S = (L/1000-day * 24*60*60-hour * 60*60-min * 60 );
  38. System. Out. println ("generated" + outputfile. getname () + "consumed:" + min + "min" + S + "Sec ");
  39. }
  40. Class testthread extends java. Lang. Thread {
  41. Public file inputfile;
  42. Public file outputfile;
  43. Public void run (){
  44. Jod4doctopdf T = new jod4doctopdf ();
  45. T.doc topdf (inputfile, outputfile );
  46. System. Out. println (outputfile. getname () + "file generated ");
  47. }
  48. }
  49. Public void test (string path, string st ){
  50. Testthread T1 = new testthread ();
  51. T1.inputfile = new file (path + st + ". Doc ");
  52. // T1.inputfile = new file (path + st + ". xls ");
  53. T1.outputfile = new file (path + st + ". pdf ");
  54. //
  55. // Testthread t2 = new testthread ();
  56. // T2.inputfile = new file ("D:/document2.doc ");
  57. // T2.outputfile = new file ("D:/document2.pdf ");
  58. //
  59. // Testthread T3 = new testthread ();
  60. // T3.inputfile = new file ("D:/document3.doc ");
  61. // T3.outputfile = new file ("D:/document3.pdf ");
  62. // T2.start ();
  63. T1.start ();
  64. // T3.start ();
  65. }
  66. Public static void main (string [] ARGs) throws exception {
  67. String Path = "d :\\"; // path of the converted file
  68. String STR = "China 2 S"; // name of the converted file
  69. Try {
  70. Jod4doctopdf P = new jod4doctopdf (); // generate a PDF
  71. P. Test (path, STR );
  72. } Catch (exception ex)
  73. {
  74. System. Out. println ("error ");
  75. }
  76. System. Out. println ("success ");
  77. }
  78. }

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

Related Article

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.