Open michcald opened 8 years ago
There is much easier way to do it without curl:
$context = stream_context_create(
[
'http' => [
'method' => 'POST',
'header' => 'Content-Type: application/json',
'content' => json_encode(
[
'contents' => base64_encode('<h1>html content here</h1>')
]
)
]
]
);
$pdf = file_get_contents("http://127.0.0.1:1234", null, $context);
pdf is created, but images does not display
I adition to nazar-pc comment, you can send wkhtmltopdf options like this.
$context = stream_context_create( [ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => json_encode( [ 'contents' => base64_encode($htmlStringView), 'options' => [ 'page-size' => 'A4', 'footer-right' => '[page]', 'margin-bottom' => '20', 'margin-top' => '20', 'footer-font-size' => '8' ] ] ) ] ] ); $pdf = file_get_contents("http://laradock_wkhtmltopdf_1/", null, $context);
Thought it might be useful for someone to see a PHP example.