First time here? Check out the FAQ!
Hi, I'm using C# to automate LibreOffice to convert documents into PDFs via the export filters. Is there a nice programmatic way to assign the export filter to a particular file type extensions? Currently my code looks like this:
switch (extension)
{
case ".doc":
case ".docx":
case ".txt":
case ".rtf":
case ".html":
case ".htm":
case ".xml":
case ".odt":
case ".wps":
case ".wpd":
case ".lwp":
return "writer_pdf_Export";
case ".xls":
case ".xlsb":
case ".xlsx":
case ".ods":
return "calc_pdf_Export";
case ".ppt":
case ".pptx":
case ".odp":
return "impress_pdf_Export";
default:
return null;
}
Obviously LibreOffice supports much more file extension than that, but was wondering if there a way to extract it via code, rather than "hard coding" with a switch statement like this.
This answer is not a solution, but it should hopefully point you in the right direction. The files containing the output filters can be found here or in /filter/source/config/fragments/filters/ if you download a copy of the source code. In simplistic terms you can extract a list of supported file extensions by running a regular expression over the files in this directory e.g.,
$ grep -hre "Extensions" /filter/source/config/fragments/types/ | grep -o "<value>.*</value>"
That will give you raw (non-type associated) output for all supported file types (including graphics formats) as shown in this file for v4.0.3.3. Obviously a more programmatic interrogation method would be required to pull out only document file types and in the groupings (writer, calc, etc. file types) you require. This is the general approach I would take.
LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!
Asked: 2012-10-30 17:04:01 +0200
Seen: 124 times
Last updated: May 21
LibreOffice PDF Export Library?
Del Operator in Libreoffice Math
Re-creating windows search filters
Disable Automatic Updates in Debian globally for all users? [closed]
Which Microsoft Office document formats are considered 100% compatible with LibreOffice 4.0?
How to set system wide options / settings / prefrences [closed]
Pics disappear from my text document
Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
The method you use will vary according to platform (GNU/Linux, MacOS, Windows, etc.) and sometimes even the desktop environment (Gnome, KDE, etc.) What platform / desktop environment are you using?
oweng ( 2013-04-03 01:22:13 +0200 )edit@S. Lock -- still looking for an answer here?
qubit ( 2013-04-27 20:25:01 +0200 )edit