[Java] Export as PDF without lauching OOo

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Korps
Posts: 2
Joined: Fri Sep 10, 2010 3:35 pm

[Java] Export as PDF without lauching OOo

Post by Korps »

Hi,
I am currently using OOo to create documents, save them, ...
My problem is that I would like to export existing document and then export it as pdf without launching OOo (I mean to load the document and then export it as pdf). I am using it in Java
It is possible or not?
I saw there is may be a way while using :

Code: Select all

xComponentLoader.loadComponentFromURL(private:stream/, "_blank", 0, loadProps);
Can you tell me if is it possible and how can I do it.
Thanks

PS : my english may be bad, i am french so I try to do my best.
OOo 3.2 on Vista
hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java] Export as PDF without lauching OOo

Post by hol.sten »

Korps wrote:My problem is that I would like to export existing document and then export it as pdf without launching OOo (I mean to load the document and then export it as pdf). I am using it in Java
It is possible or not?
No, it is not possible.
Korps wrote:PS : my english may be bad, i am french so I try to do my best.
Pas de problem. If you like you can ask in french here http://user.services.openoffice.org/fr/forum/.
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
Korps
Posts: 2
Joined: Fri Sep 10, 2010 3:35 pm

Re: [Java] Export as PDF without lauching OOo

Post by Korps »

Ok thanks,
I'll find another way.
OOo 3.2 on Vista
groverblue
Posts: 40
Joined: Wed Mar 26, 2008 6:17 pm

Re: [Java] Export as PDF without lauching OOo

Post by groverblue »

Yes you can.

Code: Select all

PropertyValue[] filterData = new PropertyValue[5];

filterData[0] = new PropertyValue();

filterData[0].Name = "UseLosslessCompression";

filterData[0].Value = Boolean.FALSE;

filterData[1] = new PropertyValue();

filterData[1].Name = "Quality";

filterData[1].Value = new Integer(50);

filterData[2] = new PropertyValue();

filterData[2].Name = "ReduceImageResolution";

filterData[2].Value = Boolean.TRUE;

filterData[3] = new PropertyValue();

filterData[3].Name = "MaxImageResolution";

filterData[3].Value = new Integer(150);

filterData[4] = new PropertyValue();

filterData[4].Name = "ExportFormFields";

filterData[4].Value = Boolean.FALSE;


pdfStoreProps = new PropertyValue[4];

pdfStoreProps[0] = new PropertyValue();

pdfStoreProps[0].Name = "FilterName";

pdfStoreProps[0].Value = "writer_pdf_Export";

pdfStoreProps[1] = new PropertyValue();

pdfStoreProps[1].Name = "Pages";

pdfStoreProps[1].Value = "All";

pdfStoreProps[2] = new PropertyValue();

pdfStoreProps[2].Name = "Overwrite";

pdfStoreProps[2].Value = Boolean.TRUE;

pdfStoreProps[3] = new PropertyValue();

pdfStoreProps[3].Name = "FilterData";

pdfStoreProps[3].Value = filterData;

            
String filePath = "/path/to/my/pdf/file.pdf";

XTextDocument xTextDocument; // or XComponent

XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);

xStorable.storeToURL("file:///" + filePath, pdfStoreProps);

xStorable = null;
groverblue
Posts: 40
Joined: Wed Mar 26, 2008 6:17 pm

Re: [Java] Export as PDF without lauching OOo

Post by groverblue »

hol.sten
Volunteer
Posts: 495
Joined: Mon Oct 08, 2007 1:31 am
Location: Hamburg, Germany

Re: [Java] Export as PDF without lauching OOo

Post by hol.sten »

groverblue wrote:Yes you can.
Even half a year later you didn't get the point of the original question? The emphasis of this thread laid on "without lauching OOo". Your answers provide only a solution for the part "Export as PDF".
OOo 3.2.0 on Ubuntu 10.04 • OOo 3.2.1 on Windows 7 64-bit and MS Windows XP
groverblue
Posts: 40
Joined: Wed Mar 26, 2008 6:17 pm

Re: [Java] Export as PDF without lauching OOo

Post by groverblue »

Relax cowboy. It isn't clear from the original post what "without launching OOo" actually means. I take that wording to mean running the GUI and selecting File > Export as PDF. If the original poster meant "without bootstrapping OOo," then it wasn't made clear.
Post Reply