Exporting to PDF failing in Windows 2019 Datacenter

The Application Programming Interface and the OASIS Open Document Format

Exporting to PDF failing in Windows 2019 Datacenter

Postby Tim Grantham » Thu May 14, 2020 10:10 pm

 Edit: There is an off-topic question for Tim in Options for "FilterName" and properties for saving PDF 
My Java app finishes by exporting a Writer document to PDF. This works perfectly when running in Windows 7 or Windows 10, but fails spectacularly when running in Windows 2019 Datacenter if the document contains any images. (It throws a java.io.EOFException.)

The Java app also saves the document in ODT and DOC format, before it exports to PDF. If I manually open the ODT document and export to PDF, there's no problem; works perfectly.

Has anyone else encountered this problem in Windows 2019 Datacenter?

Here's the code that performs the export to PDF:

Code: Select all   Expand viewCollapse view
           
// export it to PDF
     sStorePDFFileUrl.append(sSaveFileUrl + ".pdf");
     System.out.println("INFO: Exporting styled source document to PDF document \"" + sStorePDFFileUrl + "\"...");
     exportDocComponent(xDoc, sStorePDFFileUrl.toString(), "writer_pdf_Export");

...
    /** Export a document
     */
    protected static void exportDocComponent(XComponent xDoc, String storeUrl, String filterName)
            throws java.lang.Exception {

        XStorable xStorable = (XStorable) UnoRuntime.queryInterface(
                XStorable.class, xDoc);
        // September 2018: Made Tagged PDF output. Should add this as a parameter.
        PropertyValue[] storeProps = new PropertyValue[4];
        storeProps[0] = new PropertyValue();
        storeProps[0].Name = "FilterName";
        storeProps[0].Value = filterName;
        storeProps[1] = new PropertyValue();
        storeProps[1].Name = "UpdateDocMode";
        storeProps[1].Value = 3;
        storeProps[2] = new PropertyValue();
        storeProps[2].Name = "Overwrite";
        storeProps[2].Value = new Boolean(true);
        PropertyValue[] aFilterData = new PropertyValue[7];
        aFilterData[0] = new PropertyValue();
        aFilterData[0].Name = "InitialView";
        aFilterData[0].Value = 1;
        aFilterData[1] = new PropertyValue();
        aFilterData[1].Name = "Magnification";
        aFilterData[1].Value = 1;
        aFilterData[2] = new PropertyValue();
        aFilterData[2].Name = "IsSkipEmptyPages";
        aFilterData[2].Value = new Boolean(false);
        aFilterData[3] = new PropertyValue();
        //Set following to number of bookmark levels displayed initially
        aFilterData[3].Name = "OpenBookmarkLevels";
        aFilterData[3].Value = 3;
        aFilterData[4] = new PropertyValue();
        aFilterData[4].Name = "UseTaggedPDF";
        aFilterData[4].Value = new Boolean(true);
        aFilterData[5] = new PropertyValue();
        aFilterData[5].Name = "RestrictPermissions";
        aFilterData[5].Value = new Boolean(false);
        //aFilterData[6] = new PropertyValue();
        //aFilterData[6].Name = "PermissionPassword";
        //aFilterData[6].Value = "xxxxxxxxxxxxxx";
        aFilterData[6] = new PropertyValue();
        aFilterData[6].Name = "Changes";
        aFilterData[6].Value = 0;
        storeProps[3] = new PropertyValue();
        storeProps[3].Name = "FilterData";
        storeProps[3].Value = aFilterData;

        try {
            xStorable.storeToURL(storeUrl, storeProps);
        } catch (IOException e) {
            System.err.println("ERROR: IOException. Unable to export document.");
        }
    }
OpenOffice 4.1
Windows 7 Professional
Tim Grantham
 
Posts: 32
Joined: Thu Jan 06, 2011 12:03 am

Return to UNO API and ODF

Who is online

Users browsing this forum: Google [Bot] and 3 guests