Librex
Provides functions to convert office documents, spredsheets & 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.
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"}
Summary↑
convert!(in_file, out_file, soffice_cmd \\ "soffice") | The same as |
convert(in_file, out_file, soffice_cmd \\ "soffice") | Converts in_file to out_file
Returns |
supported_document_formats() | Returns supported document formats |
supported_presentation_formats() | Returns supported presentation formats |
supported_spreadsheet_formats() | Returns supported spreadsheet formats |
Functions
Converts in_file to out_file
Returns :ok
if successful, {:error, reason}
otherwise.
The same as convert/3
, but raises an exception if it fails.
Returns supported document formats
Returns supported presentation formats
Returns supported spreadsheet formats