fkrauthan / wp-mpdf

Print WordPress posts as PDF. Optional with Geshi highlighting.
56 stars 22 forks source link

Usage with output buffering #10

Closed jorisw closed 7 years ago

jorisw commented 7 years ago

Hi,

I'm trying to do the most straightforward thing I can think of, which is simply output the entire page, as it would in HTML, to PDF.

In trying to achieve this, in wp-content/wp-mpdf-themes/default.php, I'm simply doing a require() of my template for this page type:

<?php 

ob_start();

require_once(dirname(__FILE__).'/../themes/mytheme/single-posttype.php');

ob_flush();

However, something is still breaking wp-mpdf:

mPDF error: Some data has already been output to browser, can't send PDF file

The page is then displayed, in HTML, exactly as it's supposed to, but not as PDF.

What would be the right way to do this? Can I somehow return the output buffer to wp-mpdf as string?

jorisw commented 7 years ago

Posting my question in the support forum instead.