|
|
Comments and Discussions
|
|
 |

|
Hello,
I have modified the code slightly so that I can hand in source and destination path via the console.
Therefore, the ConvertToPDF function is called immediately with these two parameters. (That is the only important change)
I try to use the script in order to iterate the conversion process over a whole list of files.
This includes that the conversion programme is called many times after another.
For some reason, even though there is a waitforexit statement in the ConvertToPDF Function,
the programme does not block and it is possible to invoke the programme multiple times.
This invokesmultiple instances of openoffice converting the listed files.
Furthermore, this results in many openoffice processes which stop and do not continue.
This can be seen in the task manager. For some reason, they block each other and openoffice
does not terminate.
Somebody who knows this problem and fixed it?
|
|
|
|

|
Does someone know what I need to modify
in order to be also able to convert WORD documents of higher version
which usually carry the *.docx extension.
Help would be appreciated.
|
|
|
|

|
In theory it should work out of the box.
"...you could do conversions from any OpenOffice.org supported format to PDF because we relied - not specifying any import filter in the macro - that the document would be recognized and opened by the OpenOffice.org."
Try to do the conversion manually. Run OpenOffice and open the document, then try to save/export as PDF. If it doesn't work, it won't work from code. Try to use a newer version of OpenOffice.
good luck!
|
|
|
|

|
Hello you are correct.
It was not possible to open the document I used in OpenOffice even though it was possible in Word.
(I actually converted it from *.doc to *.docx to test, but it seems that OpenOffice does not have the capability to open such documents then)
Other *.docx which are generated as such work, though.
Thank you for your fast reply.
|
|
|
|

|
Hi
after conversion of doc to pdf using Portable open office, our application's all sessions are expired. Please guide me how to fix the issue.
Thanks
|
|
|
|

|
Hi
after conversion of doc to pdf using Portable open office, our application getting logged out. Please guide me how to fix the issue.
Thanks
|
|
|
|

|
Hi
after conversion of doc to pdf using Portable open office, our application getting logged out. Please guide me how to fix the issue.
Thanks
|
|
|
|

|
I am using this code in a file called "test.vbs".
I get an error - Error - Expected ")" - with this code
OpenOffice.Instance.ConvertToPDF(c:\a\test.doc,c:\a\test.pdf);
I get an error - Error - Cannot use parentheses when calling a sub
<pre>
OpenOffice.Instance.ConvertToPDF("c:\a\test.doc","c:\a\test.pdf");
I am actually looking for a solution to allow me to open .doc files in my perl script and create a PDF in the same directory, perl doesn't seem to do this, and so I thought I would try with this, getting perl to run the VBS.
Thats not currently my problem though! I assumed my test vbs file would work!
Am I barking up the wrong tree?
Thanks!
---Edit---
I have tried the demo app too, this throws up an error after selecting a file.
system.security.SecurityException: request for the permission of type system.security.securityPermissions.FileIOpermission
(and it goes on and on).
Any pointers would be great
modified 4-Jan-12 14:27pm.
|
|
|
|

|
Try to run OpenOffice manually and see if you can convert (export) your document to PDF and get the expected outcome. If it works, it should work from code.... as pointed out in the article: "we just execute OpenOffice.org Portable - as if we were running it from the command line - from our code, with some arguments that indicate it to run a macro which handles the conversion" You could try a newer version of OpenOfice. I haven't used this lately since I'm working with Java projects now, and there's a great library which connects to OpenOffice to do the conversion -> jodconverter[^]
I hope it had been of any help.... good luck!
|
|
|
|

|
Thanks - I did notice this was an old project and wondered if I would even get a reply, so thanks!
I can open OpenOffice, import and output a PDF just fine.
I will have a look at the JODconverter and see if I can use this, I have never looked at JAVA before, I mainly tinker with PERL, HTML and a little Javascript.
My collegues currently save quotes to a shared folder from Word, and I created a perl/javascript interface for our secured website which allows us to access the shared folder and search it's contents dynamically. I currently ask them to save the quotes as a PDF too, to make opening online easier, but this is often forgotten, and also makes altering and ammending quotes tiresome! This is why I thought I could convert the DOC's before they are downloaded, doing so each time to ensure the PDF is uptodate with the DOC.
I Assume I can somehow call some JAVA code through PERL somehow.....
|
|
|
|

|
Hi,
While word files having any images, it won't come in converted pdf file...Am i missing anything?? or is there any workaround for this?
|
|
|
|

|
Try to run OpenOffice manually and see if you can convert (export) your document to PDF and get the expected outcome. If it works, it should work from code.... as pointed out in the article: "we just execute OpenOffice.org Portable - as if we were running it from the command line - from our code, with some arguments that indicate it to run a macro which handles the conversion"
You could try a newer version of OpenOfice.
I haven't used this lately since I'm working with Java projects now, and there's a great library which connects to OpenOffice to do the conversion -> jodconverter[^]
I hope it had been of any help.... good luck!
|
|
|
|

|
Hello, the project is working, but I'm having problems when the document exists within a bar code, it appears in a PDF but figures in the document. DOC is OK! What can be? My machine works, the problem is when running on the server.
Tks!
Fernando Garcia dos Santos
Analista de sistemas
feferes.net@gmail.com
|
|
|
|

|
Hi,
I am currently referencing the PortableOpenOffice.dll in my Web Application.
I have resolved all the security permissions on the OpenOfficePortable\ which now allow my User to call the sOffice.exe. The issue I currently have is when the dlls' call (p.WaitForExit(timeout)) is called, nothing happens. The timeout expires and the (p.HasExited = false). I am unable to get a proper error.
Is there someone that has done this in a web application environment before that could either assist or possibly provide me with a working sample?
When I run the sample provided in this application, the windows forms app, the same macros I am using are being called and my documents are being exported to pdf which leads me to believe there is something else thats failing. Im currently using IIS 7.0 in Windows 7 so chances are there's something that I haven't set
Any assistance would be greatly appreciated.
modified on Wednesday, January 20, 2010 7:49 AM
|
|
|
|
|

|
Cool! thanks for sharing.
|
|
|
|

|
I have installed OO on windows server 2008...bt when i try to run..it gets crashed...
openoffice.org 3.1 has stopped working and shows follong msg..
Problem signature:
Problem Event Name: APPCRASH
Application Name: soffice.bin
Application Version: 3.1.9420.500
Application Timestamp: 4a8ad90c
Fault Module Name: ntdll.dll
Fault Module Version: 6.0.6002.18005
Fault Module Timestamp: 49e03821
Exception Code: c0000005
Exception Offset: 00049e05
OS Version: 6.0.6002.2.2.0.274.10
Locale ID: 1033
Additional Information 1: bfef
Additional Information 2: e8adce1c2b9e7be834b4063ac3c53863
Additional Information 3: bfef
Additional Information 4: e8adce1c2b9e7be834b4063ac3c53863
|
|
|
|

|
Sorry, I can't help you. If you can run OpenOffice.org Portable and do the conversion manually, chances for the code to run properly are better.
Greetings!
|
|
|
|

|
I have to put my Project and PortableOpenOffice(withn proj) at following path...is der ny workaround for that.?
it doest work for this path....
D:\serverFolder\MyProject\MyApplication\PortableOffice
|
|
|
|

|
The heart of the library is just to start openoffice with some parameteres. As I said in the article, the conversion is done by openoffice. So, after setting up the macro , you can call it with just this piece of code:
ProcessStartInfo startInfo=new ProcessStartInfo();
startInfo.CreateNoWindow=true;
startInfo.FileName="THE_PATH_TO_OPENOFFICE_EXECUTABLE";
startInfo.Arguments=String.Format("-invisible macro:///ConversionLibrary.PDFConversion.ConvertWordToPDF(\"{0}\",\"{1}\")", "SOURCE_PATH_DOC","DESTINATION_PATH_PDF");
Process p=new Process();
p.StartInfo=startInfo;
p.Start();
p.WaitForExit();
In fact, if you select the path to OpenOfficePortable/App/openoffice/program/soffice.exe instead of OpenOfficePortable/OpenOfficePortable.exe you'll see it'll run faster
|
|
|
|

|
Thanks,it worked,...but
Now rft to pdf conversion in not working.....when running application soffice windows app opens and shows
ConversionLibrary.PDFConversion..and Points to oDoc.storeToURL( cURL, _
BASIC ERROR:Object variable is not set.
is it related to alterd path i put PortableOffice\App\...soffice.exe??
|
|
|
|

|
Hi!
I don't think it has to do with the path. It wouldn't have run if it was.
Perhaps you're trying to convert a file which its path contains spaces.
If you modified the OpenOffice class or did your own procedure, make sure you are calling OpenOffice program with the filename between " characters in the arguments string.
The arguments string should be something like: -invisible macro:///ConversionLibrary.ConversionModule.Doc2PDF("source Filename with spaces.doc","destinationFilename.pdf")
Greetings!
|
|
|
|

|
I am getting an error; that "The system cannot find the file specified".
|
|
|
|
|

|
It is not answered there too...The question is raised; but no answer.
|
|
|
|
|

|
@above
Thanks. The other link that you sent me was very usefu...
|
|
|
|

|
Hi, I have modify the code, but it's stop creating when creating into 4~5 files.
private void btnConvertToPDF_Click(object sender, System.EventArgs e)
{
this.Cursor=Cursors.WaitCursor;
try
{
string FileFolderPath = textBox1.Text;
if (!Directory.Exists(FileFolderPath+@"\PDF\"))
Directory.CreateDirectory(FileFolderPath + @"\PDF\");
string[] FilesToPDF = Directory.GetFiles(FileFolderPath);
for (int i = 0; i < FilesTobeRename.Length; i++)
{
string Outpath = FileFolderPath + @"\PDF\" + Path.GetFileNameWithoutExtension(FilesToPDF[i]) + ".pdf";
if (i != 0)
{
int maxtime = 50;
for (int k = 1; k <= maxtime; k++)
{
string prpath = FileFolderPath + @"\PDF\" + Path.GetFileNameWithoutExtension(FilesToPDF[i - 1]) + ".pdf";
if (File.Exists(prpath))
{
goto CreateNext;
}
else
{
System.Threading.Thread.Sleep(500);
}
if (k == maxtime)
{
i--;
}
}
}
CreateNext:
OpenOffice.Instance.ConvertToPDF(FilesTobeRename[i], Outpath);
System.Threading.Thread.Sleep(3000);
}
}
catch(Exception exc)
{
MessageBox.Show(exc.ToString());
}
finally
{
this.Cursor=Cursors.Default;
}
}
modified on Friday, October 9, 2009 9:34 AM
|
|
|
|

|
I'm sorry I can't help you, I haven't used this code for a long time now and I never used it to convert more than one file at a time.
If you're converting at least 4~5 files, I can't understand why is it failing afterwards. I suggest you to recheck your code (cycles). Also you can make the calling of OpenOffice simpler, after all: The operation is very simple, we just execute OpenOffice.org Portable - as if we were running it from the command line - from our code, with some arguments that indicate it to run a macro which handles the conversion.
You can have more control on how to run OpenOffice by creating your own version of the main method on OpenOffice class: ConvertToPDF.
public void ConvertToPDF(string SourceFilename,string DestinationFilename)
{
ProcessStartInfo startInfo=new ProcessStartInfo();
startInfo.CreateNoWindow=true;
startInfo.FileName=GetPortableOpenOfficeExecutable();
startInfo.Arguments=String.Format("-invisible macro:///"+ConversionLibrary+"."+ConversionModule+"."+ConversionFunction+"(\"{0}\",\"{1}\")",
SourceFilename,DestinationFilename);
Process p=new Process();
p.StartInfo=startInfo;
p.Start();
p.WaitForExit();
}
|
|
|
|

|
How do I copy text from word document to use it as my email content(C#), using OpenOffice?
|
|
|
|

|
Y viva mexico cabrones!!! o no ciro_vladimir?
hi there! is there a way to catch an error when trying to open a password protected file, an invalid/fake extension (i mean, a .doc renamed to .xls what I would count like a corrupted file) or anything else that could break the oo macro?
If you try to convert an .xls book renamed to .doc, for example, oo pops up saying that "URL seems to be an unsupported one" and waits until you click "ok"... and your service will throw a TimeOut exception (and oo will wait forever for someone to click ok )... so, is there a way to catch the BASIC runtime error when trying to open the file?
Saludos!!!
|
|
|
|

|
Saludos paisano.. jeje ... siento la tardanza
Puedes implementar el manejo de errores en la Macro y no hacer nada jeje
Y verificar desde tu codigo si despues de ejecutar la macro el archivo existe jiuu
Esto evitara que se despliegue un mensaje de error en el OpenOffice.
(Abajo esta la macro modificada, quite los comentarios tambien)
Si necesitas realizar un manejo especifico de los errores, podrias empezar aqui[^]
You may handle the errors on the macro and do nothing. Then verify from your code if after calling the macro the file exists. This will avoid the error message from popping out.
(Below is the modified macro, I removed comments)
If you need to handle specific errors, try here[^]
Sub ConvertWordToPDF( cSourceFile , cDestinationFile)
On Error Goto ErrorHandler
cURL = ConvertToURL( cSourceFile )
oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, _
Array(MakePropertyValue( "Hidden", True ),) )
cURL = ConvertToURL( cDestinationFile )
oDoc.storeToURL( cURL, _
Array(MakePropertyValue( "FilterName", "writer_pdf_Export" ),)
oDoc.close( True )
On Error Goto 0
Exit Sub
ErrorHandler:
'Do nothing, check afterwards if file exists
On Error Goto 0
End Sub
modified on Tuesday, December 16, 2008 2:08 PM
|
|
|
|

|
This is really a great article and it helps me to solve the issue of document conversion that is required in an application that I'm building.
I'm buidling an application in .NET and I just called OO to convert documents to pdf. All the things work fine, the only thing I wanna improve is the large disk space occupied by OO Portable. I find that there are many files and folders in the extracted Open Office Portable. It occupies about 500 MB. So I wanna know which files / folders are not needed for document conversion?
|
|
|
|

|
What version of OpenOffice Portable are you using?
In their site[^] says version 2.4.1 should occupy 240Mb.
I have an earlier version (2.0.3) and windows explorer tell me it occupies 177Mb.
You could try installing other versions and see how they fit.
Another suggestion is to ask in their forums[^] if you can slim down PortableOpenOffice but i think that was already answered here[^].
Good luck!
|
|
|
|

|
I see. The version I'm using is 2.4.0. It takes about 500MB
ok. let me ask in the forum
|
|
|
|

|
hi, thanks for your article, i'm going to count the words in a document, i have the macro but the macro returns value, i dont know how to obtain the return value from macro in C#, i appreciate if you help me. any solution for this problem without using msoffice will be welcome
|
|
|
|

|
I'm sorry, I don't know how to do that. You could try to write to a file from the macro and read the value from your application, but that could be hard to implement.
If you are able to install open office in the computers where your application will run, I'd advice you to use CLI assemblies provided by OpenOffice. Take a look here[^]. That woul be a starting point.
I hope it can help you out ! bye!
|
|
|
|

|
Thanks for taking the time; I always wanted to know how to do this in an Open Office macro, plus I had never heard of Open Office Portable! I really learned something. - "5"
|
|
|
|

|
I'm glad to know it has helped someone. Thanks for helping others solve their problems.
|
|
|
|

|
please be asked whether can work in vs2005 for openoffice? why not work in vs2005. how to wirte when call macro .
for example :
c# :
processstartinfo startinfo
startinfo.arguments = String.Format("-invisible macro:///"+conversionlibrary + "." + conversionmodule + "." + conversionfunction+"(\"{0}\",\"{1}\")",sourcefilename,destinationfilename);
*** conversionlibrary,conversionmodule ,conversionfunction,sourcefilename and destinationfilename are variables .
but write the following commands in vb.net ,can not work
[string].format("-invisible macro:///" + conversionlibrary + "." + conversionmodule + "." + conversionfunction + "(""{0}"",""{1}"")",sourcefilename,destinationfilename)
Please help , thanks!
|
|
|
|

|
after i tried , it is good using in window application , but can not work when use in web application , i want to know how to use in web application of vs2005
|
|
|
|

|
For security reasons you can't start a process (OpenOffice in our case) from a web application. So, you need to search a way to do that.
I've found a solution but perhaps it's not the best solution. I hope it helps !
You should check why IIS is Unable to Start a Process from ASP.NET and how to fix that. Also you need to look at http://www.eggheadcafe.com/articles/20030703.asp[^] in the IIS 6.0 Isolation Modes section.
I've tested it on win2k3 server with IIS 6.0 changing the proccesModel directive in the machine.config file(first article), enabling IIS Admin Service to interact with desktop(first article) and setting IIS 6.0 in IIS 5.0 isolation mode(second article) as explained in the articles and it worked.
Good luck !!
|
|
|
|

|
Thank you for your reply very much!
But i can not do like that you said ,because my iis version is 5.1 based on window xp , Could you tell me how to do for IIS 5.1 .
thank you !
|
|
|
|

|
I'm sorry, I can't. You could try some alternatives, check HoyaSaxa93 suggestions
|
|
|
|

|
Processes in IIS by default run under the "NETWORK SERVICE" account. This account is traditionally very weak in terms of what it is allowed to do, so it is no surprise that it cannot start up or connect to Open Office. You could try configuring the account that runs in IIS to be a different more powerful one, but then it's less secure.
If the problem is easily decoupled from producing web content, I often run the privilege-needy method from across a .Net Remoting API, IPC channel, same host as the web server. The remoting server can run under a more privileged account, usually as a windows service using srvany.exe and instsrv.exe, and I can further control access by restricting the API to "safe" actions or by using windows integrated security. (But if you have a mixed Windows 2000/XP/2003 environment, it can be difficult getting integrated security to forward credentials appropriately.)
|
|
|
|

|
how to convert the following command into vb.net , please help , very hurry
//////
ProcessStartInfo startInfo=new ProcessStartInfo();
startInfo.CreateNoWindow=true;
startInfo.FileName=GetPortableOpenOfficeExecutable();
startInfo.Arguments=String.Format("-invisible macro:///"+ConversionLibrary+"."+ConversionModule+"."+
ConversionFunction+"(\"{0}\",\"{1}\")",SourceFilename,DestinationFilename);
startInfo.UseShellExecute = false;
Process p=new Process();
p.StartInfo=startInfo;
p.Start();
p.WaitForExit();
|
|
|
|

|
First, I didn't test it... i just used this[^] automatic conversion site. The result was:
Dim startInfo As New ProcessStartInfo()
startInfo.CreateNoWindow = True
startInfo.FileName = PATH_TO_SOFFICE_EXE
startInfo.Arguments = [String].Format("-invisible macro:///" + ConversionLibrary + "." + ConversionModule + "." + ConversionFunction + "(""{0}"",""{1}"")", SourceFilename, DestinationFilename)
startInfo.UseShellExecute = False
Dim p As New Process()
p.StartInfo = startInfo
p.Start()
p.WaitForExit()
NOTE: I removed the call to GetPortableOpenOfficeExecutable(), you could use the path to soffice.exe directly instead. Also, the values for ConversionLibrary,ConversionModule and ConversionFunction are "ConversionLibrary","PDFConversion" and "ConvertWordToPDF" respectively if you created the macro as explained in the article.
This lines are the core of the article, "The operation is very simple, we just execute OpenOffice.org Portable - as if we were running it from the command line - from our code with some arguments that indicate it to run a macro which handles the conversion"
I hope it helps, greetings!
|
|
|
|

|
Thank you for your reply, but still not run yet when modify coding in vb.net , and always hang , not work ,not error yet, if i run the sample application downloaded from here , it can work ,
Please help me. very hurry!
Thank you kindly ppl
|
|
|
|

|
I think your process may be hanging because you are not handling the stderr and stdout streams. There is definitely a better way, but I usually just redirect and close them Here's what I do:
int timeout = 60000; Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = <filename>;
proc.StartInfo.Arguments = <arguments>;
proc.StartInfo.WorkingDirectory = <directory you="" want="" it="" to="" start="" in="">;
proc.Start();
proc.StandardError.Close();
proc.StandardOutput.Close();
proc.WaitForExit(timeout);
if (!proc.HasExited)
{
try
{
proc.Kill();
proc.Close();
proc.Dispose();
}
catch (Exception ex)
{
err = "Exception caught: " + ex.Message;
}
}</directory></arguments></filename>
If I do not have the lines in there to Close the streams, my WaitForExit will hang until the timeout (or forever if I do not specify a timeout.)
|
|
|
|

|
I want to convert the files which transport from FileNet to PDF file,and open or save it to local.
So where can i find the OOo macro scirpt sample?
Thx your help.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
An article on using OpenOffice.org Portable to convert a Word document to PDF without requiring you to install OpenOffice.org on client machines.
| Type | Article |
| Licence | CPOL |
| First Posted | 6 Oct 2006 |
| Views | 150,510 |
| Bookmarked | 62 times |
|
|