Skip to content

etiennelacoursiere/gotenberg-elixir

Repository files navigation

gotenberg-elixir

Gotenberg Elixir

An elixir client for interacting with Gotenberg

CI Status Hex


Warning

This is a work in progress use at your own risk.

Implemented

  • health check, version
  • Chromium routes
  • LibreOffice routes
  • PDF routes

TODO

  • Metrics
  • Webhooks
  • Probably more

Quick examples

Convert a target URL to PDF

{:ok, %{body: pdf}} = GotenbergElixir.Chromium.url_into_pdf("https://example.com")
File.write!("my_pdf.pdf", pdf)

Convert html into PDF

html = "<html><body><h1>Hello World</h1></body></html>"
{:ok, %{body: pdf}} = GotenbergElixir.Chromium.html_file_into_pdf(html)
File.write!("my_pdf.pdf", pdf)

# Add header, footer, images, etc. that you can reference in your index.html
{:ok, %{body: pdf}} =
  GotenbergElixir.Chromium.html_file_into_pdf(
    html_file,
    [
      {"style.css", css_file},
      {"header.html", header_file},
      {"footer.html", footer_file}
    ]
  )

File.write!("my_pdf.pdf", pdf)

Convert Office documents to PDF

{:ok, %{body: pdf}} = GotenbergElixir.LibreOffice.convert([{"my_file.docx", docx_file}])
File.write!("my_pdf.pdf", pdf)

# You can convert multiple files at once
{:ok, %{body: pdf}} = GotenbergElixir.LibreOffice.convert([
  {"my_file.docx", docx_file},
  {"my_file.xls", xls_file},
  {"my_file.ppt", ppt_file}
])

Enum.each(body, fn {filename, content} ->
  File.write!(filename, content)
end)

About

An elixir client for interacting with Gotenberg

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published