mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-08 00:22:14 +01:00
1777 lines
148 KiB
HTML
Executable File
1777 lines
148 KiB
HTML
Executable File
<!DOCTYPE html><html><head>
|
||
|
||
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-10196481-9"></script>
|
||
<script>
|
||
window.dataLayer = window.dataLayer || [];
|
||
function gtag(){dataLayer.push(arguments);}
|
||
gtag('js', new Date());
|
||
|
||
gtag('config', 'UA-10196481-9');
|
||
</script>
|
||
<meta charset="utf-8"/>
|
||
<meta http-equiv="x-ua-compatible" content="ie=edge"/>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||
<title>Gotenberg · A Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF.</title>
|
||
<link rel="apple-touch-icon-precomposed" sizes="57x57" href="theme/gotenberg/img/apple-touch-icon-57x57.png"/>
|
||
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="theme/gotenberg/img/apple-touch-icon-114x114.png"/>
|
||
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="theme/gotenberg/img/apple-touch-icon-72x72.png"/>
|
||
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="theme/gotenberg/img/apple-touch-icon-144x144.png"/>
|
||
<link rel="apple-touch-icon-precomposed" sizes="60x60" href="theme/gotenberg/img/apple-touch-icon-60x60.png"/>
|
||
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="theme/gotenberg/img/apple-touch-icon-120x120.png"/>
|
||
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="theme/gotenberg/img/apple-touch-icon-76x76.png"/>
|
||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="theme/gotenberg/img/apple-touch-icon-152x152.png"/>
|
||
<link rel="icon" type="image/png" href="theme/gotenberg/img/favicon-196x196.png" sizes="196x196"/>
|
||
<link rel="icon" type="image/png" href="theme/gotenberg/img/favicon-96x96.png" sizes="96x96"/>
|
||
<link rel="icon" type="image/png" href="theme/gotenberg/img/favicon-32x32.png" sizes="32x32"/>
|
||
<link rel="icon" type="image/png" href="theme/gotenberg/img/favicon-16x16.png" sizes="16x16"/>
|
||
<link rel="icon" type="image/png" href="theme/gotenberg/img/favicon-128.png" sizes="128x128"/>
|
||
<link rel="stylesheet" href="theme/gotenberg/css/index.css"/>
|
||
</head>
|
||
<body>
|
||
<div class="Wrapper">
|
||
<div class="Container">
|
||
<div class="Header">
|
||
<div class="Title center">
|
||
<img src="https://user-images.githubusercontent.com/8983173/69229423-ac731300-0b85-11ea-8c2e-2cc00ecdb269.PNG" alt="Gotenberg logo" width="250" height="250"/>
|
||
<span class="text">Gotenberg</span>
|
||
<span class="subtext">A Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF.</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="Content-wrapper">
|
||
<div class="Sidebar">
|
||
<div class="Menu">
|
||
|
||
<div class="item">
|
||
<a href="#introduction">Introduction</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#install">Install</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#clients">Clients</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#environment_variables">Environment variables</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#html">HTML</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#url">URL</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#markdown">Markdown</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#office">Office</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#merge">Merge</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#timeout">Timeout</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#webhook">Webhook</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#result_filename">Result filename</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#scalability">Scalability</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#ping">Ping</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#fonts">Fonts</a>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<a href="#links">Links</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="Content">
|
||
|
||
<div class="Page" id="introduction">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="introduction" href="#introduction">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Introduction</h1>
|
||
<p><a href="https://github.com/thecodingmachine/gotenberg/">Gotenberg</a> is a Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF.</p>
|
||
|
||
<ul>
|
||
<li>HTML and Markdown conversions using Google Chrome headless</li>
|
||
<li>Office conversions (.txt, .rtf, .docx, .doc, .odt, .pptx, .ppt, .odp and so on) using <a href="https://github.com/dagwieers/unoconv">unoconv</a></li>
|
||
<li>Assets: send your header, footer, images, fonts, stylesheets and so on for converting your HTML and Markdown to beaufitul PDFs!</li>
|
||
<li>Easily interact with the API using our <a href="https://github.com/thecodingmachine/gotenberg-go-client">Go</a> and <a href="https://github.com/thecodingmachine/gotenberg-php-client">PHP</a> libraries</li>
|
||
</ul>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="install">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="install" href="#install">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Install</h1>
|
||
<p>Gotenberg is shipped within a Docker image.</p>
|
||
|
||
<p>You may start it with:</p>
|
||
|
||
<pre class="chroma">$ docker run --rm -p 3000:3000 thecodingmachine/gotenberg:6
|
||
</pre>
|
||
|
||
<blockquote>
|
||
<p>The API will be available at <a href="http://localhost:3000">http://localhost:3000</a>.</p>
|
||
</blockquote>
|
||
|
||
<p>The image uses a dedicated non-root user called <code>gotenberg</code> with uid and gid <code>1001</code>.</p>
|
||
|
||
<p>If you wish to change those uid and gid, you will have to:</p>
|
||
|
||
<ul>
|
||
<li>clone the project</li>
|
||
<li>re-build the image</li>
|
||
<li>publish the image in your own Docker registry</li>
|
||
</ul>
|
||
|
||
<p>For instance:</p>
|
||
|
||
<pre class="chroma">$ git clone https://github.com/thecodingmachine/gotenberg.git
|
||
$ make publish <span class="nv">GOTENBERG_USER_GID</span><span class="o">=</span>your_custom_gid <span class="nv">GOTENBERG_USER_UID</span><span class="o">=</span>your_custom_uid <span class="nv">DOCKER_REGISTRY</span><span class="o">=</span>your_registry <span class="nv">DOCKER_USER</span><span class="o">=</span>registry_user <span class="nv">DOCKER_PASSWORD</span><span class="o">=</span>registry_password <span class="nv">VERSION</span><span class="o">=</span>6.1.0
|
||
</pre>
|
||
|
||
<blockquote>
|
||
<p><code>master</code> branch is always up-to-date with the latest version of the API.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="install.docker_compose" href="#install.docker_compose">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Docker Compose</h2>
|
||
|
||
<p>You may also add it in your Docker Compose stack:</p>
|
||
|
||
<pre class="chroma"><span class="k">version</span><span class="p">:</span><span class="w"> </span><span class="s1">'3'</span><span class="w">
|
||
</span><span class="w">
|
||
</span><span class="w"></span><span class="k">services</span><span class="p">:</span><span class="w">
|
||
</span><span class="w">
|
||
</span><span class="w"> </span><span class="c"># your others services</span><span class="w">
|
||
</span><span class="w">
|
||
</span><span class="w"> </span><span class="k">gotenberg</span><span class="p">:</span><span class="w">
|
||
</span><span class="w"> </span><span class="k">image</span><span class="p">:</span><span class="w"> </span>thecodingmachine/gotenberg<span class="p">:</span><span class="m">6</span><span class="w">
|
||
</span></pre>
|
||
|
||
<blockquote>
|
||
<p>The API will be available under <code>gotenberg:3000</code> in your Docker Compose network.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="install.kubernetes" href="#install.kubernetes">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Kubernetes</h2>
|
||
|
||
<p>It may also be deployed with Kubernetes.</p>
|
||
|
||
<p>Make sure to provide enough memory and CPU requests (for instance <code>512Mi</code> and <code>0.2</code> CPU).</p>
|
||
|
||
<blockquote>
|
||
<p>The more resources are granted, the quicker will be the conversions.</p>
|
||
</blockquote>
|
||
|
||
<p>In the deployment specification of the pod, also specify the uid of the user <code>gotenberg</code>:</p>
|
||
|
||
<pre class="chroma">securityContext:
|
||
privileged: false
|
||
runAsUser: 1001
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="install.cloud_run_google_cloud" href="#install.cloud_run_google_cloud">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Cloud Run (Google Cloud)</h2>
|
||
|
||
<p>If you’re looking for cost savings, you might be interested by <a href="https://cloud.google.com/run">Cloud Run</a>.</p>
|
||
|
||
<p>In the following examples, we will assume your
|
||
Gotenberg API is available at <a href="http://localhost:3000">http://localhost:3000</a>.</p>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="clients">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="clients" href="#clients">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Clients</h1>
|
||
<p>We provide clients in various languages for easing the interactions with the API.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="clients.go_client" href="#clients.go_client">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go client</h2>
|
||
|
||
<pre class="chroma">$ go get -u github.com/thecodingmachine/gotenberg-go-client/v7
|
||
</pre>
|
||
|
||
<p>See also the example from the <a href="https://github.com/thecodingmachine/gotenberg-go-client/blob/master/README.md">README</a>.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="clients.php_client" href="#clients.php_client">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP client</h2>
|
||
|
||
<p>Unless your project already has a PSR7 <code>HttpClient</code>, install <code>php-http/guzzle6-adapter</code>:</p>
|
||
|
||
<pre class="chroma">$ composer require php-http/guzzle6-adapter
|
||
</pre>
|
||
|
||
<p>Then the <a href="https://github.com/thecodingmachine/gotenberg-php-client">PHP client</a>:</p>
|
||
|
||
<pre class="chroma">$ composer require thecodingmachine/gotenberg-php-client
|
||
</pre>
|
||
|
||
<p>See also the example from the <a href="https://github.com/thecodingmachine/gotenberg-php-client/blob/master/README.md">README</a>.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="clients.community_clients" href="#clients.community_clients">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Community clients</h2>
|
||
|
||
<ul>
|
||
<li><a href="https://github.com/yumauri/gotenberg-js-client">JavaScript/TypeScript client</a> by <a href="https://github.com/yumauri">yumauri</a></li>
|
||
<li><a href="https://github.com/ChangemakerStudios/GotenbergSharpApiClient">C# client</a> by <a href="https://github.com/ChangemakerStudios">ChangemakerStudios</a></li>
|
||
</ul>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="environment_variables">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables" href="#environment_variables">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Environment variables</h1>
|
||
<p>You may customize the API behaviour thanks to environment variables.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.log_level" href="#environment_variables.log_level">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Log level</h2>
|
||
|
||
<p>The API provides structured logging allowing you to have relevant information
|
||
about what’s going on.</p>
|
||
|
||
<blockquote>
|
||
<p>If a TTY is attached, the log entries are displayed in text format with colors, otherwise in JSON format.</p>
|
||
</blockquote>
|
||
|
||
<p>You may customize the severity of the log entries thanks to the environment variable <code>LOG_LEVEL</code>.</p>
|
||
|
||
<p>It accepts one of the following severities: <code>"DEBUG"</code>, <code>"INFO"</code> (default) and <code>"ERROR"</code>.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.default_listen_port" href="#environment_variables.default_listen_port">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Default listen port</h2>
|
||
|
||
<p>By default, the API will listen on port <code>3000</code>.</p>
|
||
|
||
<p>You may customize this value with the environment variable <code>DEFAULT_LISTEN_PORT</code>.</p>
|
||
|
||
<p>This environment variable accepts any string that can be turned into a port number.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.root_path" href="#environment_variables.root_path">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Root path</h2>
|
||
|
||
<p>By default, the API root path is <code>/</code>.</p>
|
||
|
||
<p>You may customize this value with the environment variable <code>ROOT_PATH</code>.</p>
|
||
|
||
<p>This environment variable accepts a string starting and ending with <code>/</code>.</p>
|
||
|
||
<p>For instance, <code>/gotenberg/</code> is a valid value while <code>gotenberg</code> is not.</p>
|
||
|
||
<blockquote>
|
||
<p>This is useful if you wish to do service discovery via URL paths.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.disable_google_chrome" href="#environment_variables.disable_google_chrome">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Disable Google Chrome</h2>
|
||
|
||
<p>In order to save some resources, the Gotenberg image accepts the environment variable <code>DISABLE_GOOGLE_CHROME</code>
|
||
for disabling Google Chrome.</p>
|
||
|
||
<p>It takes the strings <code>"0"</code> or <code>"1"</code> as value where <code>1</code> means <code>true</code></p>
|
||
|
||
<blockquote>
|
||
<p>If Google Chrome is disabled, the following conversions will <strong>not</strong> be available anymore:
|
||
<a href="#html">HTML</a>, <a href="#url">URL</a> and <a href="#markdown">Markdown</a></p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.default_google_chrome_rpcc_buffer_size" href="#environment_variables.default_google_chrome_rpcc_buffer_size">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Default Google Chrome rpcc buffer size</h2>
|
||
|
||
<p>When performing a <a href="#html">HTML</a>, <a href="#url">URL</a> or <a href="#markdown">Markdown</a> conversion, the API might return
|
||
a <code>400</code> HTTP code with the message <code>increase the Google Chrome rpcc buffer size</code>.</p>
|
||
|
||
<p>If so, you may increase this buffer size with the environment variable <code>DEFAULT_GOOGLE_CHROME_RPCC_BUFFER_SIZE</code>.</p>
|
||
|
||
<p>It takes a string representation of an int as value (e.g. <code>"1048576"</code> for 1 MB).
|
||
The hard limit is 100 MB and is defined by Google Chrome itself.</p>
|
||
|
||
<blockquote>
|
||
<p>The default Google Chrome rpcc buffer size may also be overridden per request thanks to the form field <code>googleChromeRpccBufferSize</code>.
|
||
See the <a href="#html.rpcc_buffer_size">rpcc buffer size section</a>.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.disable_libre_office_unoconv" href="#environment_variables.disable_libre_office_unoconv">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Disable LibreOffice (unoconv)</h2>
|
||
|
||
<p>You may also disable LibreOffice (unoconv) with <code>DISABLE_UNOCONV</code>.</p>
|
||
|
||
<blockquote>
|
||
<p>If LibreOffice (unoconv) is disabled, the following conversion will <strong>not</strong> be available anymore:
|
||
<a href="#office">Office</a></p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.default_wait_timeout" href="#environment_variables.default_wait_timeout">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Default wait timeout</h2>
|
||
|
||
<p>By default, the API will wait 10 seconds before it considers the conversion to be unsuccessful.
|
||
If unsucessful, it returns a <code>504</code> HTTP code.</p>
|
||
|
||
<p>You may customize this timeout thanks to the environment variable <code>DEFAULT_WAIT_TIMEOUT</code>.</p>
|
||
|
||
<p>It takes a string representation of a float as value (e.g <code>"2.5"</code> for 2.5 seconds).</p>
|
||
|
||
<blockquote>
|
||
<p>The default timeout may also be overridden per request thanks to the form field <code>waitTimeout</code>.
|
||
See the <a href="#timeout">timeout section</a>.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.maximum_wait_timeout" href="#environment_variables.maximum_wait_timeout">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Maximum wait timeout</h2>
|
||
|
||
<p>By default, the value of the form field <code>waitTimeout</code> cannot be more than 30 seconds.</p>
|
||
|
||
<p>You may increase or decrease this limit thanks to the environment variable <code>MAXIMUM_WAIT_TIMEOUT</code>.</p>
|
||
|
||
<p>It takes a string representation of a float as value (e.g <code>"2.5"</code> for 2.5 seconds).</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.default_webhook_url_timeout" href="#environment_variables.default_webhook_url_timeout">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Default webhook URL timeout</h2>
|
||
|
||
<p>By default, the API will wait 10 seconds before it considers the sending of the resulting PDF to be unsuccessful.</p>
|
||
|
||
<blockquote>
|
||
<p>See the <a href="#webhook">webhook section</a>.</p>
|
||
</blockquote>
|
||
|
||
<p>You may customize this timeout thanks to the environment variable <code>DEFAULT_WEBHOOK_URL_TIMEOUT</code>.</p>
|
||
|
||
<p>It takes a string representation of a float as value (e.g <code>"2.5"</code> for 2.5 seconds).</p>
|
||
|
||
<blockquote>
|
||
<p>The default timeout may also be overridden per request thanks to the form field <code>webhookURLTimeout</code>.
|
||
See the <a href="#webhook.timeout">webhook timeout section</a>.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.maximum_webhook_url_timeout" href="#environment_variables.maximum_webhook_url_timeout">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Maximum webhook URL timeout</h2>
|
||
|
||
<p>By default, the value of the form field <code>webhookURLTimeout</code> cannot be more than 30 seconds.</p>
|
||
|
||
<p>You may increase or decrease this limit thanks to the environment variable <code>MAXIMUM_WEBHOOK_URL_TIMEOUT</code>.</p>
|
||
|
||
<p>It takes a string representation of a float as value (e.g <code>"2.5"</code> for 2.5 seconds).</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="environment_variables.maximum_wait_delay" href="#environment_variables.maximum_wait_delay">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Maximum wait delay</h2>
|
||
|
||
<p>By default, the value of the form field <code>waitDelay</code> cannot be more than 10 seconds.</p>
|
||
|
||
<blockquote>
|
||
<p>See the <a href="#html.wait_delay">wait delay section</a>.</p>
|
||
</blockquote>
|
||
|
||
<p>You may increase or decrease this limit thanks to the environment variable <code>MAXIMUM_WAIT_DELAY</code>.</p>
|
||
|
||
<p>It takes a string representation of a float as value (e.g <code>"2.5"</code> for 2.5 seconds).</p>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="html">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="html" href="#html">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>HTML</h1>
|
||
<p>Gotenberg provides the endpoint <code>/convert/html</code> for HTML conversions.</p>
|
||
|
||
<p>It accepts <code>POST</code> requests with a <code>multipart/form-data</code> Content-Type.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="html.basic" href="#html.basic">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Basic</h2>
|
||
|
||
<p>The only requirement is to send a file named <code>index.html</code>: it is the file
|
||
which will be converted to PDF.</p>
|
||
|
||
<p>For instance:</p>
|
||
|
||
<pre class="chroma"><span class="cp"><!doctype html></span>
|
||
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">title</span><span class="p">></span>My PDF<span class="p"></</span><span class="nt">title</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">h1</span><span class="p">></span>Hello world!<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.basic.c_url" href="#html.basic.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.basic.go" href="#html.basic.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.basic.php" href="#html.basic.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="html.header_and_footer" href="#html.header_and_footer">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Header and footer</h2>
|
||
|
||
<p>You may also add a header and/or a footer in the resulting PDF.
|
||
Respectively, a file named <code>header.html</code> and <code>footer.html</code>.</p>
|
||
|
||
<p>Each of them <strong>has to be a complete HTML document</strong>:</p>
|
||
|
||
<pre class="chroma"><span class="p"><</span><span class="nt">html</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">style</span><span class="p">></span>
|
||
<span class="nt">body</span> <span class="p">{</span>
|
||
<span class="k">font-size</span><span class="p">:</span> <span class="mi">8</span><span class="kt">rem</span><span class="p">;</span>
|
||
<span class="k">margin</span><span class="p">:</span> <span class="mi">4</span><span class="kt">rem</span> <span class="kc">auto</span><span class="p">;</span>
|
||
<span class="p">}</span>
|
||
<span class="p"></</span><span class="nt">style</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">p</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"pageNumber"</span><span class="p">></</span><span class="nt">span</span><span class="p">></span> of <span class="p"><</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">"totalPages"</span><span class="p">></</span><span class="nt">span</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">p</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
|
||
</pre>
|
||
|
||
<p>The following classes allow you to inject printing values:</p>
|
||
|
||
<ul>
|
||
<li><code>date</code>: formatted print date</li>
|
||
<li><code>title</code>: document title</li>
|
||
<li><code>pageNumber</code>: current page number</li>
|
||
<li><code>totalPage</code>: total pages in the document</li>
|
||
</ul>
|
||
|
||
<p>There are some limitations:</p>
|
||
|
||
<ul>
|
||
<li>JavaScript is not executed</li>
|
||
<li>external resources are not loaded</li>
|
||
<li>the CSS properties are independant of the ones used in the <code>index.html</code> file</li>
|
||
<li><code>footer.html</code> CSS properties override the ones from <code>header.html</code></li>
|
||
<li>only fonts installed in the Docker image are loaded (see the <a href="#fonts">fonts section</a>)</li>
|
||
<li>images only work using a <code>base64</code> encoded source (<code><img src="data:image/png;base64, iVBORw0K... /></code>)</li>
|
||
<li><code>background-color</code> and <code>color</code> CSS properties require an additional <code>-webkit-print-color-adjust: exact</code> CSS property in order to work</li>
|
||
</ul>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.header_and_footer.c_url" href="#html.header_and_footer.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@header.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@footer.html <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.header_and_footer.go" href="#html.header_and_footer.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">header</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"header.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">footer</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"footer.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">Header</span><span class="p">(</span><span class="nx">header</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">Footer</span><span class="p">(</span><span class="nx">footer</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.header_and_footer.php" href="#html.header_and_footer.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$header = DocumentFactory::makeFromPath('header.html', '/path/to/file');
|
||
$footer = DocumentFactory::makeFromPath('footer.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setHeader($header);
|
||
$request->setFooter($footer);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="html.assets" href="#html.assets">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Assets</h2>
|
||
|
||
<p>You may also send additional files. For instance: images, fonts, stylesheets and so on.</p>
|
||
|
||
<p>The only requirement is to make sure that their paths
|
||
are on the same level as the <code>index.html</code> file.</p>
|
||
|
||
<p>In others words, this will work:</p>
|
||
|
||
<pre class="chroma"><span class="cp"><!doctype html></span>
|
||
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">title</span><span class="p">></span>My PDF<span class="p"></</span><span class="nt">title</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">h1</span><span class="p">></span>Hello world!<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"img.png"</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
|
||
</pre>
|
||
|
||
<p>But this won’t:</p>
|
||
|
||
<pre class="chroma"><span class="cp"><!doctype html></span>
|
||
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">title</span><span class="p">></span>My PDF<span class="p"></</span><span class="nt">title</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">h1</span><span class="p">></span>Hello world!<span class="p"></</span><span class="nt">h1</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">img</span> <span class="na">src</span><span class="o">=</span><span class="s">"/foo/img.png"</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
|
||
</pre>
|
||
|
||
<p>You may also use <em>remote</em> paths for Google fonts, images and so on.</p>
|
||
|
||
<blockquote>
|
||
<p>If you want to install fonts directly in the Gotenberg Docker image,
|
||
see to the <a href="#fonts">fonts section</a>.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.assets.c_url" href="#html.assets.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@style.css <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@img.png <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@font.woff <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.assets.go" href="#html.assets.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">style</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"style.css"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">img</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"img.png"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">font</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"font.woff"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">Assets</span><span class="p">(</span><span class="nx">style</span><span class="p">,</span> <span class="nx">img</span><span class="p">,</span> <span class="nx">font</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.assets.php" href="#html.assets.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$assets = [
|
||
DocumentFactory::makeFromPath('style.css', '/path/to/file'),
|
||
DocumentFactory::makeFromPath('img.png', '/path/to/file'),
|
||
DocumentFactory::makeFromPath('font.woff', '/path/to/file'),
|
||
];
|
||
$request = new HTMLRequest($index);
|
||
$request->setAssets($assets);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="html.paper_size_margins_orientation" href="#html.paper_size_margins_orientation">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Paper size, margins, orientation</h2>
|
||
|
||
<p>You may also customize the resulting PDF format.</p>
|
||
|
||
<p>By default, it will be rendered with <code>A4</code> size, <code>1 inch</code> margins and <code>portrait</code> orientation.</p>
|
||
|
||
<blockquote>
|
||
<p>Paper size and margins have to be provided in <code>inches</code>. Same for margins.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.paper_size_margins_orientation.c_url" href="#html.paper_size_margins_orientation.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">paperWidth</span><span class="o">=</span>8.27 <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">paperHeight</span><span class="o">=</span>11.69 <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginTop</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginBottom</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginLeft</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginRight</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">landscape</span><span class="o">=</span><span class="nb">true</span> <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.paper_size_margins_orientation.go" href="#html.paper_size_margins_orientation.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">PaperSize</span><span class="p">(</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">A4</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">Margins</span><span class="p">(</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">NoMargins</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">Landscape</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.paper_size_margins_orientation.php" href="#html.paper_size_margins_orientation.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
use TheCodingMachine\Gotenberg\Request;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setPaperSize(Request::A4);
|
||
$request->setMargins(Request::NO_MARGINS);
|
||
$request->setLandscape(true);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="html.page_ranges" href="#html.page_ranges">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Page ranges</h2>
|
||
|
||
<p>You may specify the page ranges to convert.</p>
|
||
|
||
<p>The format is the same as the one from the print options
|
||
of Google Chrome, e.g. <code>1-5,8,11-13</code>.</p>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.page_ranges.c_url" href="#html.page_ranges.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">pageRanges</span><span class="o">=</span><span class="s1">'1-3,5'</span> <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.page_ranges.go" href="#html.page_ranges.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">PageRanges</span><span class="p">(</span><span class="s">"1-3,5"</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.page_ranges.php" href="#html.page_ranges.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
use TheCodingMachine\Gotenberg\Request;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setPageRanges('1-3,5');
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="html.wait_delay" href="#html.wait_delay">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Wait delay</h2>
|
||
|
||
<p>In some cases, you may want to wait a certain amount of time to make sure the
|
||
page you’re trying to generate is fully rendered. For instance, if your page relies
|
||
a lot on JavaScript for rendering.</p>
|
||
|
||
<blockquote>
|
||
<p>The wait delay is a duration in <strong>seconds</strong> (e.g <code>2.5</code> for 2.5 seconds).</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.wait_delay.c_url" href="#html.wait_delay.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">waitDelay</span><span class="o">=</span>5.5 <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.wait_delay.go" href="#html.wait_delay.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">WaitDelay</span><span class="p">(</span><span class="mf">5.5</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.wait_delay.php" href="#html.wait_delay.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
use TheCodingMachine\Gotenberg\Request;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setWaitDelay(5.5);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="html.rpcc_buffer_size" href="#html.rpcc_buffer_size">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Rpcc buffer size</h2>
|
||
|
||
<p>The API might return a <code>400</code> HTTP code with the message <code>increase the Google Chrome rpcc buffer size</code>.</p>
|
||
|
||
<p>If so, you may increase this buffer size with a form field named <code>googleChromeRpccBufferSize</code>.</p>
|
||
|
||
<p>It takes an int as value (e.g. <code>1048576</code> for 1 MB).
|
||
The hard limit is 100 MB and is defined by Google Chrome itself.</p>
|
||
|
||
<blockquote>
|
||
<p>You may also define this value globally: see the <a href="#environment_variables.default_google_chrome_rpcc_buffer_size">environment variables</a> section.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.rpcc_buffer_size.c_url" href="#html.rpcc_buffer_size.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">googleChromeRpccBufferSize</span><span class="o">=</span><span class="m">1048576</span> <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.rpcc_buffer_size.go" href="#html.rpcc_buffer_size.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">GoogleChromeRpccBufferSize</span><span class="p">(</span><span class="mi">1048576</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="html.rpcc_buffer_size.php" href="#html.rpcc_buffer_size.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
use TheCodingMachine\Gotenberg\Request;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setGoogleChromeRpccBufferSize(1048576);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="url">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="url" href="#url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>URL</h1>
|
||
<p>Gotenberg provides the endpoint <code>/convert/url</code> for remote URL conversions.</p>
|
||
|
||
<p>It accepts <code>POST</code> requests with a <code>multipart/form-data</code> Content-Type.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="url.basic" href="#url.basic">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Basic</h2>
|
||
|
||
<p>This endpoint does not accept an <code>index.html</code> file nor assets files but a form field
|
||
named <code>remoteURL</code> instead. Otherwise, URL conversions work the same as HTML conversions.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Attention:</strong> when converting a website to PDF, you should remove all margins.
|
||
If not, some of the content of the page might be hidden.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="url.basic.c_url" href="#url.basic.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/url <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">remoteURL</span><span class="o">=</span>https://google.com <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginTop</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginBottom</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginLeft</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">marginRight</span><span class="o">=</span><span class="m">0</span> <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="url.basic.go" href="#url.basic.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewURLRequest</span><span class="p">(</span><span class="s">"https://google.com"</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">Margins</span><span class="p">(</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">NoMargins</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="url.basic.php" href="#url.basic.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\URLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$request = new URLRequest('https://google.com');
|
||
$request->setMargins(Request::NO_MARGINS);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="url.custom_http_headers" href="#url.custom_http_headers">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Custom HTTP headers</h2>
|
||
|
||
<p>You may send your own HTTP headers to the <code>remoteURL</code>.</p>
|
||
|
||
<p>For instance, by adding the HTTP header <code>Gotenberg-Remoteurl-Your-Header</code> to your request,
|
||
the API will send a request to the <code>remoteURL</code> with the HTTP header <code>Your-Header</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Attention:</strong> the API uses a canonical format for the HTTP headers:
|
||
it transforms the first
|
||
letter and any letter following a hyphen to upper case;
|
||
the rest are converted to lowercase. For example, the
|
||
canonical key for <code>accept-encoding</code> is <code>Accept-Encoding</code>.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="url.custom_http_headers.c_url" href="#url.custom_http_headers.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/url <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Gotenberg-Remoteurl-Your-Header: Foo'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">remoteURL</span><span class="o">=</span>https://google.com <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="url.custom_http_headers.go" href="#url.custom_http_headers.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewURLRequest</span><span class="p">(</span><span class="s">"https://google.com"</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">AddRemoteURLHTTPHeader</span><span class="p">(</span><span class="s">"Your-Header"</span><span class="p">,</span> <span class="s">"Foo"</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="url.custom_http_headers.php" href="#url.custom_http_headers.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\URLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$request = new URLRequest('https://google.com');
|
||
$request->addRemoteURLHTTPHeader('Your-Header', 'Foo')
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="markdown">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="markdown" href="#markdown">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Markdown</h1>
|
||
<p>Gotenberg provides the endpoint <code>/convert/markdown</code> for Markdown conversions.</p>
|
||
|
||
<p>It accepts <code>POST</code> requests with a <code>multipart/form-data</code> Content-Type.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="markdown.basic" href="#markdown.basic">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Basic</h2>
|
||
|
||
<p>Markdown conversions work the same as HTML conversions.</p>
|
||
|
||
<p>Only difference is that you have access to the Go template function <code>toHTML</code>
|
||
in the file <code>index.html</code>. This function will convert a given markdown file to HTML.</p>
|
||
|
||
<p>For instance:</p>
|
||
|
||
<pre class="chroma"><span class="cp"><!doctype html></span>
|
||
<span class="p"><</span><span class="nt">html</span> <span class="na">lang</span><span class="o">=</span><span class="s">"en"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">meta</span> <span class="na">charset</span><span class="o">=</span><span class="s">"utf-8"</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">title</span><span class="p">></span>My PDF<span class="p"></</span><span class="nt">title</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">head</span><span class="p">></span>
|
||
<span class="p"><</span><span class="nt">body</span><span class="p">></span>
|
||
{{ toHTML .DirPath "file.md" }}
|
||
<span class="p"></</span><span class="nt">body</span><span class="p">></span>
|
||
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="markdown.basic.c_url" href="#markdown.basic.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/markdown <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@file.md <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="markdown.basic.go" href="#markdown.basic.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">markdown</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"file.md"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewMarkdownRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">,</span> <span class="nx">markdown</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="markdown.basic.php" href="#markdown.basic.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\MarkdownRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$markdowns = [
|
||
DocumentFactory::makeFromPath('file.md', '/path/to/file'),
|
||
];
|
||
$request = new MarkdownRequest($index, $markdowns);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="office">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="office" href="#office">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Office</h1>
|
||
<p>Gotenberg provides the endpoint <code>/convert/office</code> for Office document conversions.</p>
|
||
|
||
<p>It accepts <code>POST</code> requests with a <code>multipart/form-data</code> Content-Type.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="office.basic" href="#office.basic">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Basic</h2>
|
||
|
||
<p>You may send one or more Office documents. Following file extensions are accepted:</p>
|
||
|
||
<ul>
|
||
<li><code>.txt</code></li>
|
||
<li><code>.rtf</code></li>
|
||
<li><code>.fodt</code></li>
|
||
<li><code>.doc</code></li>
|
||
<li><code>.docx</code></li>
|
||
<li><code>.odt</code></li>
|
||
<li><code>.xls</code></li>
|
||
<li><code>.xlsx</code></li>
|
||
<li><code>.ods</code></li>
|
||
<li><code>.ppt</code></li>
|
||
<li><code>.pptx</code></li>
|
||
<li><code>.odp</code></li>
|
||
</ul>
|
||
|
||
<p>All files will be merged into a single resulting PDF.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Attention:</strong> Gotenberg merges the PDF files alphabetically.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.basic.c_url" href="#office.basic.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/office <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@document.docx <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@document2.docx <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.basic.go" href="#office.basic.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">doc</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"document.docx"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">doc2</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"document2.docx"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewOfficeRequest</span><span class="p">(</span><span class="nx">doc</span><span class="p">,</span> <span class="nx">doc2</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.basic.php" href="#office.basic.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\OfficeRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$files = [
|
||
DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
|
||
DocumentFactory::makeFromPath('document2.docx', '/path/to/file'),
|
||
];
|
||
$request = new OfficeRequest($files);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="office.orientation" href="#office.orientation">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Orientation</h2>
|
||
|
||
<p>You may also customize the resulting PDF format.</p>
|
||
|
||
<p>By default, it will be rendered with <code>portrait</code> orientation.</p>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.orientation.c_url" href="#office.orientation.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/office <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@document.docx <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">landscape</span><span class="o">=</span><span class="nb">true</span> <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.orientation.go" href="#office.orientation.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">doc</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"document.docx"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewOfficeRequest</span><span class="p">(</span><span class="nx">doc</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">Landscape</span><span class="p">(</span><span class="kc">true</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.orientation.php" href="#office.orientation.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\OfficeRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$files = [
|
||
DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
|
||
];
|
||
$request = new OfficeRequest($files);
|
||
$request->setLandscape(true);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="office.page_ranges" href="#office.page_ranges">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Page ranges</h2>
|
||
|
||
<p>You may specify the page ranges to convert.</p>
|
||
|
||
<p>The format is the same as the one from the print options
|
||
of LibreOffice, e.g. <code>1-1</code> or <code>1-4</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Attention:</strong> if more than one document, the page ranges will be
|
||
applied for each document.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.page_ranges.c_url" href="#office.page_ranges.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/office <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@document.docx <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">pageRanges</span><span class="o">=</span><span class="s1">'1-3'</span> <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.page_ranges.go" href="#office.page_ranges.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">doc</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"document.docx"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewOfficeRequest</span><span class="p">(</span><span class="nx">doc</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">PageRanges</span><span class="p">(</span><span class="s">"1-3"</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="office.page_ranges.php" href="#office.page_ranges.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\OfficeRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$files = [
|
||
DocumentFactory::makeFromPath('document.docx', '/path/to/file'),
|
||
];
|
||
$request = new OfficeRequest($files);
|
||
$request->setPageRanges('1-3');
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="merge">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="merge" href="#merge">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Merge</h1>
|
||
<p>Gotenberg provides the endpoint <code>/merge</code> for merging PDFs.</p>
|
||
|
||
<p>It accepts <code>POST</code> requests with a <code>multipart/form-data</code> Content-Type.</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="merge.basic" href="#merge.basic">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Basic</h2>
|
||
|
||
<p>Nothing fancy here: you may send one or more PDF files and the API
|
||
will merge them and return the resulting PDF file.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Attention:</strong> Gotenberg merges the PDF files alphabetically.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="merge.basic.c_url" href="#merge.basic.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/merge <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@file.pdf <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@file2.pdf <span class="se">\
|
||
</span><span class="se"></span> -o result.pdf
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="merge.basic.go" href="#merge.basic.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">pdf</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"file.pdf"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">pdf2</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"file2.pdf"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewMergeRequest</span><span class="p">(</span><span class="nx">pdf</span><span class="p">,</span> <span class="nx">pdf2</span><span class="p">)</span>
|
||
<span class="nx">dest</span> <span class="o">:=</span> <span class="s">"result.pdf"</span>
|
||
<span class="nx">c</span><span class="p">.</span><span class="nf">Store</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">dest</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="merge.basic.php" href="#merge.basic.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\MergeRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$files = [
|
||
DocumentFactory::makeFromPath('file.pdf', '/path/to/file'),
|
||
DocumentFactory::makeFromPath('file2.pdf', '/path/to/file'),
|
||
];
|
||
$request = new MergeRequest($files);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="timeout">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="timeout" href="#timeout">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Timeout</h1>
|
||
<p>All endpoints accept a form field named <code>waitTimeout</code>.</p>
|
||
|
||
<p>The API will wait the given <strong>seconds</strong> before it considers the conversion to be unsucessful.
|
||
If unsucessful, it returns a <code>504</code> HTTP code.</p>
|
||
|
||
<p>It takes a float as value (e.g <code>2.5</code> for 2.5 seconds).</p>
|
||
|
||
<blockquote>
|
||
<p>You may also define this value globally: see the <a href="#environment_variables.default_wait_timeout">environment variables</a> section.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="timeout.examples" href="#timeout.examples">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Examples</h2>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="timeout.examples.c_url" href="#timeout.examples.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">waitTimeout</span><span class="o">=</span>2.5
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="timeout.examples.go" href="#timeout.examples.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">WaitTimeout</span><span class="p">(</span><span class="mf">2.5</span><span class="p">)</span>
|
||
<span class="nx">resp</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">c</span><span class="p">.</span><span class="nf">Post</span><span class="p">(</span><span class="nx">req</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="timeout.examples.php" href="#timeout.examples.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
use TheCodingMachine\Gotenberg\Request;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setWaitTimeout(2.5);
|
||
$dest = 'result.pdf';
|
||
$client->store($request, $dest);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="webhook">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook" href="#webhook">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Webhook</h1>
|
||
<p>All endpoints accept a form field named <code>webhookURL</code>.</p>
|
||
|
||
<p>If provided, the API will send the resulting PDF file in a <code>POST</code> request with the <code>application/pdf</code> Content-Type
|
||
to given URL.</p>
|
||
|
||
<p>By doing so, your requests to the API will be over before the conversions are actually done!</p>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.examples" href="#webhook.examples">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Examples</h2>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.examples.c_url" href="#webhook.examples.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">webhookURL</span><span class="o">=</span><span class="s1">'http://myapp.com/webhook/'</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.examples.go" href="#webhook.examples.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">WebhookURL</span><span class="p">(</span><span class="s">"http://myapp.com/webhook/"</span><span class="p">)</span>
|
||
<span class="nx">resp</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">c</span><span class="p">.</span><span class="nf">Post</span><span class="p">(</span><span class="nx">req</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.examples.php" href="#webhook.examples.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setWebhookURL('http://myapp.com/webhook/');
|
||
$resp = $client->post($request);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.timeout" href="#webhook.timeout">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Timeout</h2>
|
||
|
||
<p>If a <code>webhookURL</code> is provided, you may also send a form field named <code>webhookURLTimeout</code>.</p>
|
||
|
||
<p>The API will wait the given <strong>seconds</strong> before it considers the sending of the resulting PDF to be unsucessful.</p>
|
||
|
||
<p>It takes a float as value (e.g <code>2.5</code> for 2.5 seconds).</p>
|
||
|
||
<blockquote>
|
||
<p>You may also define this value globally: see the <a href="#environment_variables.default_webhook_url_timeout">environment variables</a> section.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.timeout.c_url" href="#webhook.timeout.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">webhookURL</span><span class="o">=</span><span class="s1">'http://myapp.com/webhook/'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">webhookURLTimeout</span><span class="o">=</span>2.5
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.timeout.go" href="#webhook.timeout.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">WebhookURL</span><span class="p">(</span><span class="s">"http://myapp.com/webhook/"</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">WebhookURLTimeout</span><span class="p">(</span><span class="mf">2.5</span><span class="p">)</span>
|
||
<span class="nx">resp</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">c</span><span class="p">.</span><span class="nf">Post</span><span class="p">(</span><span class="nx">req</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.timeout.php" href="#webhook.timeout.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setWebhookURL('http://myapp.com/webhook/');
|
||
$request->setWebhookURLTimeout(2.5);
|
||
$resp = $client->post($request);
|
||
</pre>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.custom_http_headers" href="#webhook.custom_http_headers">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Custom HTTP headers</h2>
|
||
|
||
<p>You may send your own HTTP headers to the <code>webhookURL</code>.</p>
|
||
|
||
<p>For instance, by adding the HTTP header <code>Gotenberg-Webhookurl-Your-Header</code> to your request,
|
||
the API will send a request to the <code>webhookURL</code> with the HTTP header <code>Your-Header</code>.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Attention:</strong> the API uses a canonical format for the HTTP headers:
|
||
it transforms the first
|
||
letter and any letter following a hyphen to upper case;
|
||
the rest are converted to lowercase. For example, the
|
||
canonical key for <code>accept-encoding</code> is <code>Accept-Encoding</code>.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.custom_http_headers.c_url" href="#webhook.custom_http_headers.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Gotenberg-Webhookurl-Your-Header: Foo'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">webhookURL</span><span class="o">=</span><span class="s1">'http://myapp.com/webhook/'</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.custom_http_headers.go" href="#webhook.custom_http_headers.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">WebhookURL</span><span class="p">(</span><span class="s">"http://myapp.com/webhook/"</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">AddWebhookURLHTTPHeader</span><span class="p">(</span><span class="s">"Your-Header"</span><span class="p">,</span> <span class="s">"Foo"</span><span class="p">)</span>
|
||
<span class="nx">resp</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">c</span><span class="p">.</span><span class="nf">Post</span><span class="p">(</span><span class="nx">req</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="webhook.custom_http_headers.php" href="#webhook.custom_http_headers.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setWebhookURL('http://myapp.com/webhook/');
|
||
$request->addWebhookURLHTTPHeader('Your-Header', 'Foo');
|
||
$resp = $client->post($request);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="result_filename">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="result_filename" href="#result_filename">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Result filename</h1>
|
||
<p>All endpoints accept a form field named <code>resultFilename</code>.</p>
|
||
|
||
<p>If provided, the API will return the resulting PDF file with the given filename.
|
||
Otherwise a random filename is used.</p>
|
||
|
||
<blockquote>
|
||
<p><strong>Attention:</strong> this feature does not work if the form field <code>webhookURL</code> is given.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="result_filename.examples" href="#result_filename.examples">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Examples</h2>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="result_filename.examples.c_url" href="#result_filename.examples.c_url">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>cURL</h3>
|
||
|
||
<pre class="chroma">$ curl --request POST <span class="se">\
|
||
</span><span class="se"></span> --url http://localhost:3000/convert/html <span class="se">\
|
||
</span><span class="se"></span> --header <span class="s1">'Content-Type: multipart/form-data'</span> <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">files</span><span class="o">=</span>@index.html <span class="se">\
|
||
</span><span class="se"></span> --form <span class="nv">resultFilename</span><span class="o">=</span><span class="s1">'foo.pdf'</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="result_filename.examples.go" href="#result_filename.examples.go">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Go</h3>
|
||
|
||
<pre class="chroma"><span class="kn">import</span> <span class="s">"github.com/thecodingmachine/gotenberg-go-client/v7"</span>
|
||
|
||
<span class="nx">c</span> <span class="o">:=</span> <span class="o">&</span><span class="nx">gotenberg</span><span class="p">.</span><span class="nx">Client</span><span class="p">{</span><span class="nx">Hostname</span><span class="p">:</span> <span class="s">"http://localhost:3000"</span><span class="p">}</span>
|
||
<span class="nx">index</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewDocumentFromPath</span><span class="p">(</span><span class="s">"index.html"</span><span class="p">,</span> <span class="s">"/path/to/file"</span><span class="p">)</span>
|
||
<span class="nx">req</span> <span class="o">:=</span> <span class="nx">gotenberg</span><span class="p">.</span><span class="nf">NewHTMLRequest</span><span class="p">(</span><span class="nx">index</span><span class="p">)</span>
|
||
<span class="nx">req</span><span class="p">.</span><span class="nf">ResultFilename</span><span class="p">(</span><span class="s">"foo.pdf"</span><span class="p">)</span>
|
||
<span class="nx">resp</span><span class="p">,</span> <span class="nx">_</span> <span class="o">:=</span> <span class="nx">c</span><span class="p">.</span><span class="nf">Post</span><span class="p">(</span><span class="nx">req</span><span class="p">)</span>
|
||
</pre>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="result_filename.examples.php" href="#result_filename.examples.php">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>PHP</h3>
|
||
|
||
<pre class="chroma">use TheCodingMachine\Gotenberg\Client;
|
||
use TheCodingMachine\Gotenberg\DocumentFactory;
|
||
use TheCodingMachine\Gotenberg\HTMLRequest;
|
||
use TheCodingMachine\Gotenberg\Request;
|
||
|
||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||
$index = DocumentFactory::makeFromPath('index.html', '/path/to/file');
|
||
$request = new HTMLRequest($index);
|
||
$request->setResultFilename('foo.pdf');
|
||
$resp = $client->post($request);
|
||
</pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="scalability">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="scalability" href="#scalability">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Scalability</h1>
|
||
<p>The API uses under the hood intricate programs.</p>
|
||
|
||
<p>Gotenberg tries to abstract as much complexity as possible but it can
|
||
only do it to a certain extent.</p>
|
||
|
||
<p>For instance, <a href="#office">Office</a> and <a href="#merge">Merge</a> endpoints will start respectively as many LibreOffice (unoconv) and PDTk
|
||
instances as there are requests. The limitation here is the available memory and CPU usage.</p>
|
||
|
||
<p>On another hand, for the <a href="#html">HTML</a>, <a href="#url">URL</a> and <a href="#markdown">Markdown</a> endpoints, the API does only 6 conversions in parallel.
|
||
Indeed, Google Chrome misbehaves if there are too many concurrent conversions.</p>
|
||
|
||
<p><strong>The more concurrent requests, the more <code>504</code> HTTP codes the API will return.</strong></p>
|
||
|
||
<blockquote>
|
||
<p>See our <a href="https://github.com/thecodingmachine/gotenberg/tree/master/loadtesting">load testing use case</a> for more details about the API behaviour under heavy load.</p>
|
||
</blockquote>
|
||
|
||
<h2 class="Heading"><a class="Anchor" aria-hidden="true" id="scalability.strategies" href="#scalability.strategies">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Strategies</h2>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="scalability.strategies.increase_timeout" href="#scalability.strategies.increase_timeout">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Increase timeout</h3>
|
||
|
||
<p>You may increase the conversion timeout. In other words, you accept that a conversion takes more time
|
||
if the API is under heavy load.</p>
|
||
|
||
<blockquote>
|
||
<p>See <a href="#timeout">timeout section</a>.</p>
|
||
</blockquote>
|
||
|
||
<h3 class="Heading"><a class="Anchor" aria-hidden="true" id="scalability.strategies.scaling" href="#scalability.strategies.scaling">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Scaling</h3>
|
||
|
||
<p>The API being stateless, you may scale it as much as you want.</p>
|
||
|
||
<p>For instance, using the following Docker Compose file:</p>
|
||
|
||
<pre class="chroma"><span class="k">version</span><span class="p">:</span><span class="w"> </span><span class="s1">'3'</span><span class="w">
|
||
</span><span class="w">
|
||
</span><span class="w"></span><span class="k">services</span><span class="p">:</span><span class="w">
|
||
</span><span class="w">
|
||
</span><span class="w"> </span><span class="c"># your others services</span><span class="w">
|
||
</span><span class="w">
|
||
</span><span class="w"> </span><span class="k">gotenberg</span><span class="p">:</span><span class="w">
|
||
</span><span class="w"> </span><span class="k">image</span><span class="p">:</span><span class="w"> </span>thecodingmachine/gotenberg<span class="p">:</span><span class="m">6</span><span class="w">
|
||
</span></pre>
|
||
|
||
<p>You may now launch your services using:</p>
|
||
|
||
<pre class="chroma">$ docker-compose up --scale <span class="nv">gotenberg</span><span class="o">=</span>your_number_of_instances
|
||
</pre>
|
||
|
||
<p>When requesting the Gotenberg service with your client(s), Docker will automatically
|
||
redirect a request to a Gotenberg container according to the round-robin strategy.</p>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="ping">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="ping" href="#ping">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Ping</h1>
|
||
<p>Gotenberg provides the endpoint <code>/ping</code> for checking the API availability with
|
||
a simple <code>GET</code> request.</p>
|
||
|
||
<p>Currently this endpoint does nothing special. A better way to monitor
|
||
Gotenberg would be by checking the memory usage.</p>
|
||
|
||
<p>Also, as the API uses under the hood intricate programs, you should
|
||
restart your Gotenberg instances from time to time to ensure a nominal behaviour.</p>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="fonts">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="fonts" href="#fonts">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Fonts</h1>
|
||
<p>By default, a handful of fonts are installed. Asian characters are also supported out of the box.</p>
|
||
|
||
<p>If you wish to use more fonts, you will have to create your own image:</p>
|
||
|
||
<pre class="chroma"><span class="k">FROM</span><span class="s"> thecodingmachine/gotenberg:6</span><span class="err">
|
||
</span><span class="err">
|
||
</span><span class="err"></span><span class="k">USER</span><span class="s"> root</span><span class="err">
|
||
</span><span class="err">
|
||
</span><span class="err"></span><span class="k">RUN</span> apt-get -y install yourfonts<span class="err">
|
||
</span><span class="err">
|
||
</span><span class="err"></span><span class="k">USER</span><span class="s"> gotenberg</span><span class="err">
|
||
</span></pre>
|
||
|
||
</div>
|
||
|
||
<div class="Page" id="links">
|
||
<h1 class="Heading"><a class="Anchor" aria-hidden="true" id="links" href="#links">
|
||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
|
||
</a>Links</h1>
|
||
<p align="center">
|
||
<img src="https://user-images.githubusercontent.com/8983173/50009948-84b01e00-ffb8-11e8-850b-fc240382c626.png" alt="Gotenberg logo" width="150" height="150"/>
|
||
</p>
|
||
|
||
<ul>
|
||
<li>Follow the progress on the <a href="https://github.com/thecodingmachine/gotenberg">GitHub repository</a></li>
|
||
<li>Follow <a href="https://twitter.com/gulnap">@gulnap</a> on Twitter</li>
|
||
<li>Thanks to <a href="https://github.com/mafredri">@mafredri</a> for its help and its wonderful <a href="https://github.com/mafredri/cdp">cdp</a> library</li>
|
||
</ul>
|
||
|
||
</div>
|
||
|
||
<div class="Footer">
|
||
</div>
|
||
<script src="theme/gotenberg/js/index.js"></script>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
</div></body></html> |