Skip to main content

Helpcenter

Converting and Printing

Writing a program that can render Office files (for converting and printing) would be equal to rewriting Office which is little out of the scope of this project. The OpenXML Libraries uses Microsoft Office or Open Office to open a file and print or save as a different file type. Microsoft Office is used on Windows and Open Office is used on UNIX/Linux or as a free alternative to Microsoft Office on Windows. Microsoft Office is 100% compatibile with OpenXML files

And Open Office compatibility with OpenXML is very good and improving with every release but is not perfect.

The OpenXML Libraries also supports the odf-converter-integrator tool for conversion. The odf-converter-integrator is an open source project from Novell in co-operation with Microsoft. The odf-converter-integrator can be downloaded at

http://katana.oooninja.com/w/odf-converter-integrator/download

The odf-converter-integrator currently produces better results converting Word .DOCX files to Open Office .ODT files than Open Office. The OpenXML Libraries uses the odf-converter-integrator to convert the Word files to Open Office files before opening them in Open Office (The OpenXML Libraries can also use the odf-converter-integrator alone to convert OpenXML files to Open Office files and vice versa). If you are using Open Office it is recommended to also install the odf-converter-integrator to improve results.

Note: the file types supported depends on the tools used. The libraries can use both etc.

Note: microsoft office compatibility pack for earlier versions. Not about the service pack etc.

Note: Microsoft office 2007 sp1 support for pdf, xps.

Note: open office version required 3.0, recommended the latest version. Open office version 3.1 had issues with Excel Pivot Tables.

Note: Converting and printing the first file may take longer because Microsoft Office or Open Office has to be loaded first. To make Open Office load quicker, in the Tools menu, Options, click on Memory and change Number of steps to 30, Use for OpenOffice.org to 128MB, Memory per object to 20MB, Number of objects to 20 and select Load OpenOffice.org during system start-up checkbox (the last quick start option is only available on Windows).

Converting
Sample 3

/* sample3.p */

{slibooxml/slibooxml.i}

{slib/slibos.i}

{slib/sliberr.i}

define var cError as char no-undo.

define var cErrorMsg as char no-undo.

define var cStackTrace as char no-undo.

{slib/err_try}:

run ooxml_convert(

input "item.xlsx",

input os_getNextFile( session:temp-dir + "item.pdf" ),

input ? ).

run ooxml_convert(

input "sale_order.docx",

input os_getNextFile( session:temp-dir + "sale_order.pdf" ),

input ? ).

{slib/err_catch cError cErrorMsg cStackTrace}:

message

cErrorMsg

skip(1)

cStackTrace

view-as alert-box.

{slib/err_end}.

Explanation

The slibooxml/slibooxml.i is a general purpose OpenXML Library used for printing and converting.

The ooxml_convert procedure converts one file type (even files that are not OpenXML files) to other file types and has the following parameters:

  1. Source file.

  2. Target file.

  3. Optional formatting.

The ooxml_convert procedure identifies the file types to convert based on the file extension. For example: run ooxml_convert( "test.docx", "test.pdf" ) converts a Word file to a PDF file.

Printing
Sample 4

/* sample3.p */

{slibooxml/slibooxml.i}

{slib/slibos.i}

{slib/sliberr.i}

define var cError as char no-undo.

define var cErrorMsg as char no-undo.

define var cStackTrace as char no-undo.

{slib/err_try}:

run ooxml_print(

input "sale_order.docx",

input "<printer-name>",

input ? ).

{slib/err_catch cError cErrorMsg cStackTrace}:

message

cErrorMsg

skip(1)

cStackTrace

view-as alert-box.

{slib/err_end}.

Explanation

The ooxml_print procedure prints a file out to a printer (even files that are not OpenXML files) and has the following parameters:

  1. Source file.

  2. Printer name.

  3. Number of copies:

    The number of copies parameter is optional. If a zero 0 or null ? value is passed. a single copy will be printed.

  4. Optional formatting.

Open Office Compatibility Issues

Open Office compatibility with OpenXML is very good but it's not perfect. Open Office compatibility has improved since it was first released in version 3.0 and it's improving with every new release. Below is list of issues and fixes.

This section covers Open Office compatibility and not another Office suite because it is probably the most widely used Office suite after Microsoft Office for working with OpenXML files and the OpenXML Libraries uses it for converting and printing.

Right-to-Left Issues

If you're using tables in Word, right-click the table, Table Properties, Table tab and make sure the Table direction is left-to-right.