« MBS Xojo Plugins, ver… | Home | ChartDirector PDF Out… »

Convert office documents to PDF with LibreOffice


Did you know you can use LibreOffice to convert your Word, Excel or Powerpoint documents to PDF files?

You can learn about command line commands in the help: Starting the LibreOffice Software With Parameters.

To show an example, let us convert a Word file to PDF on MacOS:

/Applications/LibreOffice.app/Contents/MacOS/soffice --convert-to pdf --outdir /Users/cs/Desktop /Users/cs/Documents/test.doc

or Windows:

"C:\Program Files\LibreOffice\program\soffice.exe" --convert-to pdf --outdir C:\Users\Christian\Desktop C:\Users\Christian\Desktop\test.docx
To run this, you can use Shell class in Xojo or Shell functions for FileMaker in MBS Plugin.

In Xojo, you can run this with the Shell class like this:

dim InputFile as FolderItem = SpecialFolder.Desktop.Child("test2.docx")
dim OutputFolder as FolderItem = SpecialFolder.Desktop

const AppPath = "C:\Program Files\LibreOffice\program\soffice.exe"
dim AppFile as new FolderItem(AppPath, FolderItem.PathModes.Native)

dim cmd as string = AppFile.ShellPath+ " --convert-to pdf --outdir " + OutputFolder.ShellPath + " " + InputFile.ShellPath

dim sh as new shell
sh.execute cmd

Enjoy conversion! The biggest plugin in space...
17 06 20 - 12:23