OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Silent Mode Conversion

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Mon Jul 16, 2012 1:24 am    Post subject: Silent Mode Conversion Reply with quote

I am using this code to convert .odt file into Microsoft Office doc.

Code:

private static void saveDocument(XComponent xComponent, string sourceFile, string destinationFile)
        {
            //destinationFile = "file:///C:/Documents and Settings/User/My Documents/Harry_Home_Bill_Receip.doc";
            //string destinationFile1 = destinationFile;
            //destinationFile1 = destinationFile1.Replace(".odt", ".doc");

            PropertyValue[] propertyValues = new PropertyValue[1];
            propertyValues[0] = new PropertyValue();
            propertyValues[0].Name = "Overwrite";
            propertyValues[0].Value = new uno.Any("MS Word 2007");
            //((XStorable)xComponent).storeToURL(destinationFile, propertyValues);
            XStorable xcomponent1 = (xComponent) as XStorable;
            xcomponent1.storeToURL(destinationFile, propertyValues);
        }


This code seems to work perfectly fine. The only thing is while converting it unncessarily displays "Open Office Start Up Screen" is there a way it can do it in silent mode by not displaying the open office start up screen?
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Mon Jul 16, 2012 5:06 am    Post subject: Reply with quote

Really no experience at all here but I think you need:

Code:
oooOptions.add("-nofirststartwizard");


and/or

Code:
oooOptions.add("-headless");


somewhere maybe. (You are using Java?).

You do know about JodConverter?
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Mon Jul 16, 2012 11:08 pm    Post subject: Reply with quote

Robert Tucker wrote:
Really no experience at all here but I think you need:

Code:
oooOptions.add("-nofirststartwizard");


and/or

Code:
oooOptions.add("-headless");


somewhere maybe. (You are using Java?).

You do know about JodConverter?


I am using these Java SDKs in C#

Code:

// Open Office Namespaces
using unoidl.com.sun.star.lang;
using unoidl.com.sun.star.uno;
using unoidl.com.sun.star.bridge;
using unoidl.com.sun.star.frame;
using unoidl.com.sun.star.beans;
using System.Diagnostics;


The code snippt that you've mentioned, where should I add it? what is oooOptions?
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Tue Jul 17, 2012 12:41 am    Post subject: Reply with quote

How about this:

Code:
private static void StartOpenOffice()
        {
            Process[] ps = Process.GetProcessesByName("soffice.exe");
            if (ps != null)
            {
                if (ps.Length > 0)
                    return;
                else
                {
                    Process p = new Process();
                    p.StartInfo.Arguments = "-headless -nofirststartwizard";
                    p.StartInfo.FileName = "soffice.exe";
                    p.StartInfo.CreateNoWindow = true;
                    bool result = p.Start();
                    if (result == false)
                        throw new InvalidProgramException("OpenOffice failed to start.");
                }
            }
            else
            {
                throw new InvalidProgramException("OpenOffice not found.  Is OpenOffice installed?");
            }
        }


http://stackoverflow.com/questions/1868974/openoffice-pdf-export-library

On Linux you need to install a headless package; I don't know if that's also the case on Windows.
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Tue Jul 17, 2012 2:08 am    Post subject: Reply with quote

Robert Tucker wrote:
How about this:

Code:
private static void StartOpenOffice()
        {
            Process[] ps = Process.GetProcessesByName("soffice.exe");
            if (ps != null)
            {
                if (ps.Length > 0)
                    return;
                else
                {
                    Process p = new Process();
                    p.StartInfo.Arguments = "-headless -nofirststartwizard";
                    p.StartInfo.FileName = "soffice.exe";
                    p.StartInfo.CreateNoWindow = true;
                    bool result = p.Start();
                    if (result == false)
                        throw new InvalidProgramException("OpenOffice failed to start.");
                }
            }
            else
            {
                throw new InvalidProgramException("OpenOffice not found.  Is OpenOffice installed?");
            }
        }


http://stackoverflow.com/questions/1868974/openoffice-pdf-export-library

On Linux you need to install a headless package; I don't know if that's also the case on Windows.


Thanks. I am working on 64-bit Windows 7 I will try this code. Although in 32-bit Windows XP it doesn't display that start up screen. I have another query. What all DLLs do I need if I have to make my application work on PCs that don't have Open Office Software installed? Because this application has to be deployed on user PCs and they don't need a 140MB open office software to be installed in order to run this application?
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Tue Jul 17, 2012 2:45 am    Post subject: Reply with quote

maverick786us wrote:
What all DLLs do I need if I have to make my application work on PCs that don't have Open Office Software installed? Because this application has to be deployed on user PCs and they don't need a 140MB open office software to be installed in order to run this application?

I'm not aware anything has changed in this respect since 2006, but I may be wrong:

http://www.oooforum.org/forum/viewtopic.phtml?t=47733
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Tue Jul 17, 2012 3:03 am    Post subject: Reply with quote

Found this thread:

http://stackoverflow.com/questions/4017886/how-to-convert-odt-to-doc-rtf-without-openoffice-org

Aspose is a little pricey?
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Tue Jul 17, 2012 3:53 am    Post subject: Reply with quote

That looks like some kind of incomplete solution. So I have to convince the client that every end user needs Open Office to be installed in order to convert it? There is another problem I just noticed.

Code:

private static void saveDocument(XComponent xComponent, string sourceFile, string destinationFile)
        {
            //destinationFile = "file:///C:/Documents and Settings/User/My Documents/Harry_Home_Bill_Receip.doc";
            //string destinationFile1 = destinationFile;
            //destinationFile1 = destinationFile1.Replace(".odt", ".doc");

            PropertyValue[] propertyValues = new PropertyValue[1];
            propertyValues[0] = new PropertyValue();
            propertyValues[0].Name = "Overwrite";
            propertyValues[0].Value = new uno.Any("MS Word 2003 XML");
            //((XStorable)xComponent).storeToURL(destinationFile, propertyValues);
            XStorable xcomponent1 = (xComponent) as XStorable;
            xcomponent1.storeToURL(destinationFile, propertyValues);
        }


I just installed MS Office 2010 in my PC and when i open a converted document in MS Word it says the file is corrupted and the input text gets messed up. Can someoen tell me if the problem is with this section of code or something else?

Code:

propertyValues[0].Value = new uno.Any("MS Word 2003 XML");


Previously ity was uno.Any("MS Word 2007") then I changed it into uno.Any("MS Word 2003") and then uno.Any("MS Word 2003 XML"); and in all three cases it generated error. Unfortunately there is no option of attachment I would have showed the ODT and converted file.
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Tue Jul 17, 2012 11:24 pm    Post subject: Re: Silent Mode Conversion Reply with quote

Hi,
maverick786us wrote:
I am using this code to convert .odt file into Microsoft Office doc.

Code:
(...)

            PropertyValue[] propertyValues = new PropertyValue[1];
            propertyValues[0] = new PropertyValue();
            propertyValues[0].Name = "Overwrite";
            propertyValues[0].Value = new uno.Any("MS Word 2007");
            XStorable xcomponent1 = (xComponent) as XStorable;
            xcomponent1.storeToURL(destinationFile, propertyValues);


This code seems to work perfectly fine.

Really ? I had some doubts... Do you really think that property OverWrite could have a value like "MS Word 2007" ?
Quote:
just installed MS Office 2010 in my PC and when i open a converted document in MS Word it says the file is corrupted and the input text gets messed up


What you want to do is called : exporting.
Read the example at bottom of this page.
Read also Developer's Guide Storing Documents.
_________________
Bernard

OpenOffice.org 1.1.5 fr / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Wed Jul 18, 2012 12:59 am    Post subject: Re: Silent Mode Conversion Reply with quote

B Marcelly wrote:
Hi,
maverick786us wrote:
I am using this code to convert .odt file into Microsoft Office doc.

Code:
(...)

            PropertyValue[] propertyValues = new PropertyValue[1];
            propertyValues[0] = new PropertyValue();
            propertyValues[0].Name = "Overwrite";
            propertyValues[0].Value = new uno.Any("MS Word 2007");
            XStorable xcomponent1 = (xComponent) as XStorable;
            xcomponent1.storeToURL(destinationFile, propertyValues);


This code seems to work perfectly fine.

Really ? I had some doubts... Do you really think that property OverWrite could have a value like "MS Word 2007" ?
Quote:
just installed MS Office 2010 in my PC and when i open a converted document in MS Word it says the file is corrupted and the input text gets messed up


What you want to do is called : exporting.
Read the example at bottom of this page.
Read also Developer's Guide Storing Documents.


I suspected that so i even changed it to "MS Wird 2003", "MS Word 2003 XML" and even "Microsoft Word 97/2000/XP" but none of it generated the same result Sad
Back to top
View user's profile Send private message
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Fri Jul 20, 2012 2:10 am    Post subject: Re: Silent Mode Conversion Reply with quote

B Marcelly wrote:
Hi,
maverick786us wrote:
I am using this code to convert .odt file into Microsoft Office doc.

Code:
(...)

            PropertyValue[] propertyValues = new PropertyValue[1];
            propertyValues[0] = new PropertyValue();
            propertyValues[0].Name = "Overwrite";
            propertyValues[0].Value = new uno.Any("MS Word 2007");
            XStorable xcomponent1 = (xComponent) as XStorable;
            xcomponent1.storeToURL(destinationFile, propertyValues);


This code seems to work perfectly fine.

Really ? I had some doubts... Do you really think that property OverWrite could have a value like "MS Word 2007" ?
Quote:
just installed MS Office 2010 in my PC and when i open a converted document in MS Word it says the file is corrupted and the input text gets messed up


What you want to do is called : exporting.
Read the example at bottom of this page.
Read also Developer's Guide Storing Documents.


So what should be instead of this

Code:
propertyValues[0].Value = new uno.Any("MS Word 2007");
Back to top
View user's profile Send private message
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Fri Jul 20, 2012 2:10 am    Post subject: Re: Silent Mode Conversion Reply with quote

B Marcelly wrote:
Hi,
maverick786us wrote:
I am using this code to convert .odt file into Microsoft Office doc.

Code:
(...)

            PropertyValue[] propertyValues = new PropertyValue[1];
            propertyValues[0] = new PropertyValue();
            propertyValues[0].Name = "Overwrite";
            propertyValues[0].Value = new uno.Any("MS Word 2007");
            XStorable xcomponent1 = (xComponent) as XStorable;
            xcomponent1.storeToURL(destinationFile, propertyValues);


This code seems to work perfectly fine.

Really ? I had some doubts... Do you really think that property OverWrite could have a value like "MS Word 2007" ?
Quote:
just installed MS Office 2010 in my PC and when i open a converted document in MS Word it says the file is corrupted and the input text gets messed up


What you want to do is called : exporting.
Read the example at bottom of this page.
Read also Developer's Guide Storing Documents.


So what should be instead of this

Code:
propertyValues[0].Value = new uno.Any("MS Word 2007");
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Fri Jul 20, 2012 4:01 am    Post subject: Reply with quote

Hi,
First : don't quote an answer in extenso.
Second : don't repeat the same message if you don't get answer. It's like spam. Messages are read, if the readers have time, and answered it they feel like it, and if they have something useful to add.
_________________
Bernard

OpenOffice.org 1.1.5 fr / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
maverick786us
General User
General User


Joined: 11 Jul 2012
Posts: 26

PostPosted: Mon Aug 13, 2012 9:09 pm    Post subject: Reply with quote

Robert Tucker wrote:
How about this:

Code:
private static void StartOpenOffice()
        {
            Process[] ps = Process.GetProcessesByName("soffice.exe");
            if (ps != null)
            {
                if (ps.Length > 0)
                    return;
                else
                {
                    Process p = new Process();
                    p.StartInfo.Arguments = "-headless -nofirststartwizard";
                    p.StartInfo.FileName = "soffice.exe";
                    p.StartInfo.CreateNoWindow = true;
                    bool result = p.Start();
                    if (result == false)
                        throw new InvalidProgramException("OpenOffice failed to start.");
                }
            }
            else
            {
                throw new InvalidProgramException("OpenOffice not found.  Is OpenOffice installed?");
            }
        }


http://stackoverflow.com/questions/1868974/openoffice-pdf-export-library

On Linux you need to install a headless package; I don't know if that's also the case on Windows.


I use Windows not LINUX. This code works perfect in Windows. But there is a small problem. It premanently disables Open Office. If I want to use open office for some other purpose it doen't open. So how can i overcome this limitation?
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Tue Aug 14, 2012 12:19 am    Post subject: Reply with quote

http://scott.yang.id.au/2009/11/how-to-run-multipleconcurrent-openoffice-org-instances-on-windows/
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group