Recent Updates Toggle Comment Threads | Keyboard Shortcuts
-
munim
-
munim
HOW TO: Convert office documents to PDF using Open Office in C#
THIS BLOG POST HAS GOT ITS NEW HOME
http://abdulmunim.com/how-to-convert-office-documents-to-pdf-using-open-office-in-c/
-
Carl Cubillas
Hi there, great article. Do you know a way to convert doc/docx to PDF without using major application such as OO or MS Word?
-
munim
Hi,
I myself had to go for OpenOffice as I couldn’t find any free solution regarding this. The drawback is, your sever need to have OpenOffice installed 😦 There’s definitely a lot of proprietary libraries that allows to convert documents to PDF. Aspose.Words for .NET is a good one that I know of!
-
ranadheer
hi munim
i have tried the above code but am getting the XComponent NULL can u please solve my problem….
-
munim
XComponent is null when OpenOffice instance is not running. Please check your system’s security privileges and the instance is running.
-
-
Keith Cromm
This might be helpful to some in regards to getting the Open Office bin path into the environment variable,
.Net: Working with OpenOffice 3
http://blog.nkadesign.com/2008/net-working-with-openoffice-3/
-
Keith Cromm
This also might be helpful:
http://stackoverflow.com/questions/7685661/programmatically-convert-word-docx-tot-pdf
-
-
Chris
How can I convert a file to a pdf/a instead of a pdf. I know there is a “SelectPdfVersion” property for the open office API but I dont know how to use it with .Net
-
Ramon
GREAT article man. Very well explained, not just a bunch of code. I have a question: would it be advisable to use a portable version of openoffice? I don’t like the idea of having OpenOffice (or any other office suite) actually installed on my server.
Would the source code be very different if I want to execute a portable edition of OO?
Again, thanks and congrats!
-
David
did you find a way to use portable version ?
-
-
Rushabh Patel
I have a open office and open office sdk installed in my machine. but still getting error..how to use dll’s of open office ?
-
PASena
[Error]
Could not load file or assembly ‘cli_cppuhelper, Version=1.0.22.0, Culture=neutral, PublicKeyToken=ce2cb7e279207b9e’ or one of its dependencies. The system cannot find the file specified.[Web.Config]
cli_cppuhelper is registred
what am I doing wrong?
-
john
Hi, I keep getting the following error… System.MissingMemberException: Public member ‘getServiceManager’ on type ‘Object’ not found. at Microsoft.VisualBasic.CompilerServices.Symbols.Container.GetMembers(String& MemberName, Boolean ReportErrors) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
-
Thiago (@thdotnet)
Is there a way to do the same task without install de Open Office, only working with the SDK dll’s?
-
munim
Well, I haven’t found any free solution for this. You may check this StackOverflow question for some paid solution they have provided.
-
-
kmi_4k
This topic must help you:
http://www.oooforum.org/forum/viewtopic.phtml?t=193243 -
stevens
You can convert all office documents to PDF by using Aspose .NET Component below is the link i hope it will be useful for many users:
-
Jingle
Hi munim,
This is great article. I find it more useful. But there is one thing I want to know. Is this can be applied using windows service running on ther server?
-
Jingle
Hi there,
How can I set the spreadsheet or excel page scale? so i can able to see the page to fit? What I mean is I can able to see the converted pdf without missing any content of it. I tried converting excel to pdf but some of the content are cut and then some of it are place in another page. pls help. thank you in advance.
-
Richard
Hi, thanks for your article. But I had a problem about it. When I ran the code, it showed me an error: URL seems to be unsupported one. I thought it was happened in “PathConverter” function. The code: return String.format(“file:///{0}”, file.Replace(@”\”,”/”)), did it return a file include Url, right?
-
jeevan reddy
its working when i hoste in iis 7 not working
-
emily
There is a C#/.NET Library available for converting word document to PDF known as Aspose.Words for .NET. Below is the link of this API you can try it:
-
woolf
Hi munim, thanks a lot. Your article saved me many hours of work.
For me, it worked all well on my development machine but after deployment
it started hanging at the ” var xLocalContext = Bootstrap.bootstrap(); ” line and not returning a response.
As for the solution, running Open Office as a Windows service on the server and using “LocalSystem” as application pool identity worked for me.
These links may be useful if anyone else has the same problem :
http://stackoverflow.com/questions/15388526/openoffice-uno-util-bootstrap-bootstrap-hangs-and-does-not-return
http://blog.a25apps.com/2009/09/29/run-openoffice-org-3-as-windows-service-updated-instructions/ -
Jessica
I did everything as stated here, however for some reason it doesn’t conduct conversion. Are there some extra tips or settings that should be applied?
-
Anurag
I m stuck in the while loop, not getting out. Plz reply
-
Amol
reported error is:
map_to_uno (): [] com.sun.star.beans.PropertyValue] conversion failed
[map_to_uno ( ): unoidl.com.sun.star.beans.PropertyValue.Value [map_to_uno (): any] could not convert type! -
Naveed
I was able to find a low cost but excellent solution, there is nothing out there Free to convert docx to PDF
since office 2013 things have gone complicated. , I am posting this in case it is help full to someone. I am not related to this company. here is the link: http://www.gemboxsoftware.com/ . These people have unlimited server licensing. 🙂 at a low cost.
Open office will not convert Office SDK documents properly to PDF. It will convert OO documents properly -
Randall
Hi,
this example rocks, well done.
We are however noticing that after about a week or two of use our app stops working and need to be restarted. any idea why Open office might be choking after a while -
Surya
yes above code is working, so is any way to convert doc file to docx file ?
-
randall
Munim,
this was a great article.. While the code works fine for a while, it stops working after about a week or two if you are running it as background process. It appears that this is a issue with OpenOffice.Have you run into this and if so how did you resolve this?
-
Ivan
StartOpenOffice() code seems weird. If ps.Length is greater than 0, it will throw “OpenOffice not found. Is OpenOffice installed?” exception. but second check has early return if process is found. Also on my machine I can find process under “soffice” without “.exe”
Siva 5:55 pm on October 1, 2013 Permalink |
“and execute the command below:” — where are the commands ?? I am not able to see that.. 😦
Esha 8:06 pm on November 17, 2014 Permalink |
Not Working. I did not have the keys present under my Microsoft Key.. So I created them manually. Still not able to log in . Please help