Closed siamkreative closed 9 years ago
What it could look like with the 2nd API I mentioned.
$url = 'http://freehtmltopdf.com';
$data = array(
'convert' => '',
'html' => $_POST['html'],
'baseurl' => 'http://labs.siamkreative.com/contract-killer-generator/'
);
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
// set the pdf data as download content:
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="contract-'.$_POST['customername'].'.pdf"');
var_dump($result);
Biased, but https://docraptor.com is a great option (although not free)
Thanks @JamesPaden but I'd like to keep the service free for both users and I. html2pdfrocket.com will become paid on July 1st, so I gotta find a replacement. Perhaps a self hosted PHP script.
Several services and scripts listed here: http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php
Understandable. We're listed on that page as well, but from our testing, the best open-source/free solution is wkhtmltopdf, or a tool that uses it like Snappy - but that requires a server of some sort.
https://parall.ax/products/jspdf might be an option for you, but that's not HTML to pdf.
James, I'll try https://parall.ax/products/jspdf and host everything on https://surge.sh/. I'll do that tomorrow
I'm looking for a more reliable API to do the HTML to PDF conversion. The current one doesn't render well and it's sometimes super slow.
Actually, at the moment something went wrong and the PDF aren't created. That's probably my fault...
How about one of these?