mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fix PhantomJS support for multi-page tables and PDF page sizes
This commit is contained in:
parent
d68040897f
commit
91d90c87b3
@ -83,10 +83,19 @@ class Phantom
|
|||||||
info($url);
|
info($url);
|
||||||
|
|
||||||
$key = config( 'ninja.phantomjs_key' );
|
$key = config( 'ninja.phantomjs_key' );
|
||||||
$secret = config('ninja.phantomjs_key');
|
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/";
|
||||||
|
$pdf = CurlUtils::post( $phantom_url, json_encode( [
|
||||||
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D";
|
'url' => $url,
|
||||||
$pdf = CurlUtils::get($phantom_url);
|
'renderType' => 'pdf',
|
||||||
|
'outputAsJson' => false,
|
||||||
|
'renderSettings' => [
|
||||||
|
'emulateMedia' => 'print',
|
||||||
|
'pdfOptions' => [
|
||||||
|
'preferCSSPageSize' => true,
|
||||||
|
'printBackground' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
] ) );
|
||||||
|
|
||||||
$this->checkMime($pdf, $invitation, $entity);
|
$this->checkMime($pdf, $invitation, $entity);
|
||||||
|
|
||||||
@ -100,14 +109,20 @@ class Phantom
|
|||||||
|
|
||||||
public function convertHtmlToPdf($html)
|
public function convertHtmlToPdf($html)
|
||||||
{
|
{
|
||||||
$hash = Str::random(32);
|
|
||||||
Cache::put($hash, $html, 300);
|
|
||||||
|
|
||||||
$url = route('tmp_pdf', ['hash' => $hash]);
|
|
||||||
info($url);
|
|
||||||
$key = config( 'ninja.phantomjs_key' );
|
$key = config( 'ninja.phantomjs_key' );
|
||||||
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/?request=%7Burl:%22{$url}%22,renderType:%22pdf%22%7D";
|
$phantom_url = "https://phantomjscloud.com/api/browser/v2/{$key}/";
|
||||||
$pdf = CurlUtils::get($phantom_url);
|
$pdf = CurlUtils::post( $phantom_url, json_encode( [
|
||||||
|
'content' => $html,
|
||||||
|
'renderType' => 'pdf',
|
||||||
|
'outputAsJson' => false,
|
||||||
|
'renderSettings' => [
|
||||||
|
'emulateMedia' => 'print',
|
||||||
|
'pdfOptions' => [
|
||||||
|
'preferCSSPageSize' => true,
|
||||||
|
'printBackground' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
] ) );
|
||||||
|
|
||||||
$response = Response::make($pdf, 200);
|
$response = Response::make($pdf, 200);
|
||||||
$response->header('Content-Type', 'application/pdf');
|
$response->header('Content-Type', 'application/pdf');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user