Jump to content

Dompdf


stijn0713

Recommended Posts

Anybody experience with dompdf? 

 

i follow the basics to make a pdf from html using 

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("factuur.pdf");

It seems i can't open a pdf created with dompdf if i echo something or if there is html besides the html contained by $html. anybody know why?

Link to comment
Share on other sites

Never worked with it. But it is likely that it is sending the raw PDF data with a proper Content-Type header. If you send any other output, then the data received by the browser is NOT a valid PDF file.

 

If you want to modify or augment the output, you should probably load the HTML into a DOM object, do the updates in the DOM, generate the DOM to an HTML string, then load THAT string into the DOMPDF.

 

Edit: Unless, of course, DOMPDF, has methods for allowing you to do the changes directly to that object.

Edited by DavidAM
Link to comment
Share on other sites

i guess you are right, but i don't understand the solution. 

 

I opened the pdf file with notepad, and the problem is that all the html content is included before the actual %PDF-1.3 line. 

 

I guess a solution would be to put the intended content with the css in an outputbuffer and write in to a file, and then in that file i make pdf? (is this similiar to what you meant DavidAM?)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.