librex v1.0.4 Librex
Provides functions to convert office documents, spreadsheets & presentations to other formats.
LibreOffice must be installed. It's recommended that you add the soffice binary your PATH. Otherwise you have to specify the absolute path to the soffice binary as the last parameter.
Examples
iex(1)> Librex.convert("test/fixtures/docx.docx", "/Users/ricn/docx.pdf")
{:ok, "/Users/ricn/docx.pdf"}
iex(2)> Librex.convert("non_existent_file", "/Users/ricn/docx.pdf")
{:error, :enoent}
iex(3)> Librex.convert!("test/fixtures/docx.docx", "/Users/ricn/docx.pdf")
"/Users/ricn/docx.pdf"
iex(4)> Librex.convert!("non_existent_file", "/Users/ricn/docx.pdf")
** (File.Error) could not read non_existent_file: no such file or directory (librex) lib/librex.ex:13: Librex.convert!/3
iex(5)> Librex.convert("test/fixtures/docx.docx", "/Users/ricn/docx.pdf", "/path_to/soffice")
{:ok, "/Users/ricn/docx.pdf"}
Link to this section Summary
Link to this section Functions
convert(in_file, out_file, soffice_cmd \\ "soffice")
Converts in_file to out_file
Returns :ok
if successful, {:error, reason}
otherwise.
convert!(in_file, out_file, soffice_cmd \\ "soffice")
The same as convert/3
, but raises an exception if it fails.
supported_document_formats()
Returns supported document formats
supported_presentation_formats()
Returns supported presentation formats
supported_spreadsheet_formats()
Returns supported spreadsheet formats