Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $PDFContent = "page HTML CONTENT";
- //API URL
- $url = 'http://freehtmltopdf.com';
- //API PARAMS
- $data = array('convert' => '',
- 'html' => $PDFContent,
- 'baseurl' => base_url(),
- 'width' => '210mm',
- 'enablejs' => 0,
- 'orientation' => 'portrait');
- // 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)),);
- //PREPARE OPTIONS VARIABLE
- $context = stream_context_create($options);
- //GET PDF CONTENT
- $result = file_get_contents($url, false, $context);
- // set the pdf data as download content:
- header('Content-type: application/pdf');
- //OPEN PDF FILE IN YOUR BROWSER
- echo $result;
Advertisement
Add Comment
Please, Sign In to add comment