gotenberg_pdf

Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

Gotenberg API client.

Implementations§

Source§

impl Client

Source

pub fn new(base_url: &str) -> Self

Create a new instance of the API client.

Source

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.

Source

pub async fn pdf_from_url( &self, url: &str, options: WebOptions, ) -> Result<Bytes, Error>

Convert a URL to a PDF using the Chromium engine.

Source

pub async fn pdf_from_html( &self, html: &str, options: WebOptions, ) -> Result<Bytes, Error>

Convert HTML to a PDF using the Chromium engine.

Source

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.

Source

pub async fn screenshot_url( &self, url: &str, options: ScreenshotOptions, ) -> Result<Bytes, Error>

Take a screenshot of a webpage using the Chromium engine.

Source

pub async fn screenshot_html( &self, html: &str, options: ScreenshotOptions, ) -> Result<Bytes, Error>

Take a screenshot of an HTML page using the Chromium engine.

Source

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.

Source

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 .zabw
Source

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.

Source

pub async fn read_metadata( &self, pdf_bytes: Vec<u8>, ) -> Result<HashMap<String, Value>, Error>

Read the metadata of a PDF file

Source

pub async fn write_metadata( &self, pdf_bytes: Vec<u8>, metadata: HashMap<String, Value>, ) -> Result<Bytes, Error>

Write metadata to a PDF file

Source

pub async fn health_check(&self) -> Result<Health, Error>

Get the health status of the Gotenberg server.

Source

pub async fn version(&self) -> Result<String, Error>

Get the version of the Gotenberg server.

Source

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_size Current number of Chromium conversion requests waiting to be treated.
  • {namespace}_chromium_restarts_count Current number of Chromium restarts.
  • {namespace}_libreoffice_requests_queue_size Current number of LibreOffice conversion requests waiting to be treated.
  • {namespace}_libreoffice_restarts_count Current number of LibreOffice restarts.

Trait Implementations§

Source§

impl Clone for Client

Source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Client

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T