Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index

Hello! This is my first post to this list. 

We have a large number of PDF documents that we need to modify slightly and 
save. After a fair amount of research, it seems like the LibreOffice API and the code sample should get me rather close to the mark. I almost 
have the script working, but I'm having trouble telling libreoffice to open the 
PDF as a PDF rather than a text document. The result is a bunch of 

Here's the file I started with:

I'm running on a spare desktop system, Fedora 21, fresh install, all updates 
applied. EG: 

I've successfully modified the script so that it finds and opens the example PDF 
I'm using, which has been provided to have the same text as the example. When it opens the file, it's not importing the PDF, 
instead it's reading it as a text file or something. 

You can see what this looks like here: (I'm not running headless on purpose)

Looking at the documentation, it looks like there's an "Arguments" parameter 
which reads: 

"Arguments    these arguments specify component or filter specific behavior

For example, "ReadOnly" with a boolean value specifies whether the document
is opened read-only. "FilterName" specifies the component type to create
and the filter to use, for example: "Text - CSV". For more information see


This leads to TypeDetection but I have not figured out how to find out what 
"FilterName" I should use to specify that I'm importing a PDF. 

Below is the code fragment that I'm using now. My *guess* is that this line is 
the culprit: 

        loadProps[0].Value = "X-Application/PDF";

but I can't be sure. I'm guessing the following references are related, but 
nowhere am I seeing a *list* of import filters that I can use, nor a way to find 
out what filters are available in my install.

Applicable snippet below, the full .java script that I'm using is visible

---- SNIP ------
//        String sURL = "private:factory/" + sDocumentType;

//      String sURL = "file:///home/ben/pdf/example.pdf";
        String sURL = "file:///home/ben/pdf/example.pdf";
 xComponent = null; xComponentLoader = null;
// xEmptyArgs[] =
//            new[0];[] loadProps =

        loadProps[0] = new;
        loadProps[0].Name = "FilterData";
        loadProps[0].Value = "X-Application/PDF";

        try {
            xComponentLoader = UnoRuntime.queryInterface(
      , xDesktop);

            xComponent  = xComponentLoader.loadComponentFromURL(
                sURL, "_blank", 0, loadProps);
---- SNIP ------

Your time and attention are much appreciated. 

Benjamin Smith 

To unsubscribe e-mail to:
Posting guidelines + more:
List archive:
All messages sent to this list will be publicly archived and cannot be deleted


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.