| View previous topic :: View next topic |
| Author |
Message |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Mon Jul 16, 2012 1:24 am Post subject: Silent Mode Conversion |
|
|
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 |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Mon Jul 16, 2012 5:06 am Post subject: |
|
|
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? _________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Mon Jul 16, 2012 11:08 pm Post subject: |
|
|
| 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 |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Tue Jul 17, 2012 12:41 am Post subject: |
|
|
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. _________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Tue Jul 17, 2012 2:08 am Post subject: |
|
|
| 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 |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Tue Jul 17, 2012 2:45 am Post subject: |
|
|
| 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 _________________ LibreOffice 3.6.6 on Fedora 18, LibreOffice 4.0.2 on Ubuntu 13.04 (Double Boot) |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
|
| Back to top |
|
 |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Tue Jul 17, 2012 3:53 am Post subject: |
|
|
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 |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Tue Jul 17, 2012 11:24 pm Post subject: Re: Silent Mode Conversion |
|
|
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 / OpenOffice.org 3.4.1 en-US + langpacks, MS-Windows XP Home SP3
This forum is unusable, use instead Apache OpenOffice forums |
|
| Back to top |
|
 |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Wed Jul 18, 2012 12:59 am Post subject: Re: Silent Mode Conversion |
|
|
| 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  |
|
| Back to top |
|
 |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Fri Jul 20, 2012 2:10 am Post subject: Re: Silent Mode Conversion |
|
|
| 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 |
|
 |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Fri Jul 20, 2012 2:10 am Post subject: Re: Silent Mode Conversion |
|
|
| 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 |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Fri Jul 20, 2012 4:01 am Post subject: |
|
|
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 / OpenOffice.org 3.4.1 en-US + langpacks, MS-Windows XP Home SP3
This forum is unusable, use instead Apache OpenOffice forums |
|
| Back to top |
|
 |
maverick786us General User

Joined: 11 Jul 2012 Posts: 26
|
Posted: Mon Aug 13, 2012 9:09 pm Post subject: |
|
|
| 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 |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
|
| Back to top |
|
 |
|