An elixir client for interacting with Gotenberg
Warning
This is a work in progress use at your own risk.
- health check, version
- Chromium routes
- LibreOffice routes
- PDF routes
- Metrics
- Webhooks
- Probably more
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)