Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create pdf with DOM PDF outside DOMpdf directory

Hi I have mybb installed on my website. I have also installed dompdf and its working in its own directory i.e. I have installed in "DOM" directory. Now I can easily general pdfs with this simple code , keeping in the "DOM" directory.

<?php
require_once "dompdf_config.inc.php";
//$file = "www/test/css_at_font_face.html"; 
$file="msf.html";
$dompdf = new DOMPDF();
$dompdf->load_html_file($file);
$dompdf->render();
$dompdf->stream("sample.pdf");

?>

If I try to access other file that is out the director DOM i.e.

load_html_file($file); $dompdf->render(); $dompdf->stream("sample.pdf");

?> I receive error Remote file requested, but DOMPDF_ENABLE_REMOTE is false

like image 740
Muhammad Arslan Jamshaid Avatar asked Jan 30 '13 19:01

Muhammad Arslan Jamshaid


People also ask

How to use dom PDF in PHP?

Advanced UsageGet content from HTML file using file_get_contents() function in PHP. Load HTML content using loadHtml() method of Dompdf class. Control the PDF output using stream() function of Dompdf class. $filename – (string) Name of the PDF file.

What is Dom PDF?

Dompdf is an HTML to PDF converter At its heart, dompdf is (mostly) a CSS 2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements.

How can I create multiple PDF using Dompdf in PHP?

If you wish to generate multiple pdf files in one go, you must save the documents in the server and then use JavaScript for-loop inside AJAX and pass the files one by one in the background. This will not kill the loop process since AJAX runs in the background.

How do I save Dompdf generated content?

'templating system. </p>'. '</body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $output = $dompdf->output(); file_put_contents('Brochure. pdf', $output);


1 Answers

For enabling remote access DO NOT edit "dompdf_config.inc.php"

Use instead:

$dompdf = new DOMPDF();
$dompdf->set_option('enable_remote', TRUE);

$dompdf->set_option('enable_css_float', TRUE);
$dompdf->set_option('enable_html5_parser', FALSE);
like image 193
NBPalomino Avatar answered Sep 22 '22 05:09

NBPalomino