pub struct Client { /* private fields */ }Expand description
Gotenberg API client.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new_with_auth(base_url: &str, username: &str, password: &str) -> Self
pub fn new_with_auth(base_url: &str, username: &str, password: &str) -> Self
Create a new instance of the API client with basic auth.
You can set the username and password on the Gotenberg server by starting it with --api-enable-basic-auth and supplying GOTENBERG_API_BASIC_AUTH_USERNAME and GOTENBERG_API_BASIC_AUTH_PASSWORD environment variables.
Sourcepub async fn pdf_from_url(
&self,
url: &str,
options: WebOptions,
) -> Result<Bytes, Error>
pub async fn pdf_from_url( &self, url: &str, options: WebOptions, ) -> Result<Bytes, Error>
Convert a URL to a PDF using the Chromium engine.
Sourcepub async fn pdf_from_html(
&self,
html: &str,
options: WebOptions,
) -> Result<Bytes, Error>
pub async fn pdf_from_html( &self, html: &str, options: WebOptions, ) -> Result<Bytes, Error>
Convert HTML to a PDF using the Chromium engine.
Sourcepub async fn pdf_from_markdown(
&self,
html_template: &str,
markdown: HashMap<&str, &str>,
options: WebOptions,
) -> Result<Bytes, Error>
pub async fn pdf_from_markdown( &self, html_template: &str, markdown: HashMap<&str, &str>, options: WebOptions, ) -> Result<Bytes, Error>
Convert Markdown to a PDF using the Chromium engine.
The HTML template should in the following format:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My PDF</title>
</head>
<body>
{{ toHTML "file.md" }}
</body>
</html>The markdown files should be in a “filename” => “content” format. The filename key string must end with .md.
Sourcepub async fn screenshot_url(
&self,
url: &str,
options: ScreenshotOptions,
) -> Result<Bytes, Error>
pub async fn screenshot_url( &self, url: &str, options: ScreenshotOptions, ) -> Result<Bytes, Error>
Take a screenshot of a webpage using the Chromium engine.
Sourcepub async fn screenshot_html(
&self,
html: &str,
options: ScreenshotOptions,
) -> Result<Bytes, Error>
pub async fn screenshot_html( &self, html: &str, options: ScreenshotOptions, ) -> Result<Bytes, Error>
Take a screenshot of an HTML page using the Chromium engine.
Sourcepub async fn screenshot_markdown(
&self,
html_template: &str,
markdown: HashMap<&str, &str>,
options: ScreenshotOptions,
) -> Result<Bytes, Error>
pub async fn screenshot_markdown( &self, html_template: &str, markdown: HashMap<&str, &str>, options: ScreenshotOptions, ) -> Result<Bytes, Error>
Take a screenshot of a set of markdown files using the Chromium engine.
Sourcepub async fn pdf_from_doc(
&self,
filename: &str,
bytes: Vec<u8>,
options: DocumentOptions,
) -> Result<Bytes, Error>
pub async fn pdf_from_doc( &self, filename: &str, bytes: Vec<u8>, options: DocumentOptions, ) -> Result<Bytes, Error>
Convert a document to a PDF using the LibreOffice engine.
Supports the following file formats:
.123 .602 .abw .bib .bmp .cdr .cgm .cmx .csv .cwk .dbf .dif .doc
.docm .docx .dot .dotm .dotx .dxf .emf .eps .epub .fodg .fodp .fods
.fodt .fopd .gif .htm .html .hwp .jpeg .jpg .key .ltx .lwp .mcw .met
.mml .mw .numbers .odd .odg .odm .odp .ods .odt .otg .oth .otp .ots .ott
.pages .pbm .pcd .pct .pcx .pdb .pdf .pgm .png .pot .potm .potx .ppm .pps
.ppt .pptm .pptx .psd .psw .pub .pwp .pxl .ras .rtf .sda .sdc .sdd .sdp .sdw
.sgl .slk .smf .stc .std .sti .stw .svg .svm .swf .sxc .sxd .sxg .sxi .sxm
.sxw .tga .tif .tiff .txt .uof .uop .uos .uot .vdx .vor .vsd .vsdm .vsdx
.wb2 .wk1 .wks .wmf .wpd .wpg .wps .xbm .xhtml .xls .xlsb .xlsm .xlsx .xlt
.xltm .xltx .xlw .xml .xpm .zabwSourcepub async fn convert_pdf(
&self,
pdf_bytes: Vec<u8>,
pdfa: Option<PDFFormat>,
pdfua: bool,
) -> Result<Bytes, Error>
pub async fn convert_pdf( &self, pdf_bytes: Vec<u8>, pdfa: Option<PDFFormat>, pdfua: bool, ) -> Result<Bytes, Error>
Transforms a PDF file into the requested PDF/A format and/or PDF/UA.
Sourcepub async fn read_metadata(
&self,
pdf_bytes: Vec<u8>,
) -> Result<HashMap<String, Value>, Error>
pub async fn read_metadata( &self, pdf_bytes: Vec<u8>, ) -> Result<HashMap<String, Value>, Error>
Read the metadata of a PDF file
Sourcepub async fn write_metadata(
&self,
pdf_bytes: Vec<u8>,
metadata: HashMap<String, Value>,
) -> Result<Bytes, Error>
pub async fn write_metadata( &self, pdf_bytes: Vec<u8>, metadata: HashMap<String, Value>, ) -> Result<Bytes, Error>
Write metadata to a PDF file
Sourcepub async fn health_check(&self) -> Result<Health, Error>
pub async fn health_check(&self) -> Result<Health, Error>
Get the health status of the Gotenberg server.
Sourcepub async fn metrics(&self) -> Result<String, Error>
pub async fn metrics(&self) -> Result<String, Error>
Get the metrics of the Gotenberg server in prometheus format. The results will not be parsed and are returned as a multi-line string.
By default the namespace is gotenberg, but this can be changed by passing --prometheus-namespace to the Gotenberg server on startup.
{namespace}_chromium_requests_queue_sizeCurrent number of Chromium conversion requests waiting to be treated.{namespace}_chromium_restarts_countCurrent number of Chromium restarts.{namespace}_libreoffice_requests_queue_sizeCurrent number of LibreOffice conversion requests waiting to be treated.{namespace}_libreoffice_restarts_countCurrent number of LibreOffice restarts.