mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-14 19:32:15 +01:00
adding PHP example for custom HTTP headers in documentation + improving logs for custom HTTP headers
This commit is contained in:
@@ -233,7 +233,7 @@ Gotenberg API is available at <a href="http://localhost:3000">http://localhost:3
|
||||
<pre class="chroma">$ composer require php-http/guzzle6-adapter
|
||||
</pre>
|
||||
|
||||
<p>Then the PHP client:</p>
|
||||
<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>
|
||||
@@ -474,7 +474,7 @@ use TheCodingMachine\Gotenberg\HTMLRequest;
|
||||
$client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\Client());
|
||||
$index = DocumentFactory::makeFromPath('index.html', 'index.html');
|
||||
$request = new HTMLRequest($index);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -569,7 +569,7 @@ $footer = DocumentFactory::makeFromPath('footer.html', 'footer.html&
|
||||
$request = new HTMLRequest($index);
|
||||
$request->setHeader($header);
|
||||
$request->setFooter($footer);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -665,7 +665,7 @@ $assets = [
|
||||
];
|
||||
$request = new HTMLRequest($index);
|
||||
$request->setAssets($assets);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -731,7 +731,7 @@ $request = new HTMLRequest($index);
|
||||
$request->setPaperSize(Request::A4);
|
||||
$request->setMargins(Request::NO_MARGINS);
|
||||
$request->setLandscape(true);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -787,7 +787,7 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\
|
||||
$index = DocumentFactory::makeFromPath('index.html', 'index.html');
|
||||
$request = new HTMLRequest($index);
|
||||
$request->setWaitDelay(5.5);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -846,7 +846,7 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\
|
||||
$index = DocumentFactory::makeFromPath('index.html', 'index.html');
|
||||
$request = new HTMLRequest($index);
|
||||
$request->setGoogleChromeRpccBufferSize(1048576);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -912,7 +912,7 @@ 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";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -955,7 +955,15 @@ canonical key for <code>accept-encoding</code> is <code>Accept-Encoding</code>.<
|
||||
<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>
|
||||
|
||||
<p>// TODO</p>
|
||||
<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>
|
||||
|
||||
@@ -1030,7 +1038,7 @@ $markdowns = [
|
||||
DocumentFactory::makeFromPath('file.md', 'file.md'),
|
||||
];
|
||||
$request = new MarkdownRequest($index, $markdowns);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -1111,7 +1119,7 @@ $files = [
|
||||
DocumentFactory::makeFromPath('document2.docx', 'document2.docx'),
|
||||
];
|
||||
$request = new OfficeRequest($files);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -1164,7 +1172,7 @@ $files = [
|
||||
];
|
||||
$request = new OfficeRequest($files);
|
||||
$request->setLandscape(true);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -1229,7 +1237,7 @@ $files = [
|
||||
DocumentFactory::makeFromPath('file2.pdf', 'file2.pdf'),
|
||||
];
|
||||
$request = new MergeRequest($files);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -1292,7 +1300,7 @@ $client = new Client('http://localhost:3000', new \Http\Adapter\Guzzle6\
|
||||
$index = DocumentFactory::makeFromPath('index.html', 'index.html');
|
||||
$request = new HTMLRequest($index);
|
||||
$request->setWaitTimeout(2.5);
|
||||
$dest = "result.pdf";
|
||||
$dest = 'result.pdf';
|
||||
$client->store($request, $dest);
|
||||
</pre>
|
||||
|
||||
@@ -1449,7 +1457,17 @@ canonical key for <code>accept-encoding</code> is <code>Accept-Encoding</code>.<
|
||||
<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>
|
||||
|
||||
<p>// TODO</p>
|
||||
<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', 'index.html');
|
||||
$request = new HTMLRequest($index);
|
||||
$request->setWebhookURL('http://myapp.com/webhook/');
|
||||
$request->addWebhookURLHTTPHeader('Your-Header', 'Foo');
|
||||
$resp = $client->post($request);
|
||||
</pre>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user