• Resolved jorisw

    (@jorisw)


    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();

    The page is then displayed, in HTML, exactly as it’s supposed to, but not as PDF. It would appear something is still breaking wp-mpdf:

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

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jorisw

    (@jorisw)

    To partially answer my own question, adding the following at the beginning:

    global $pdf_output;

    And this at the end:

    $pdf_output = ob_get_contents();

    … instead of ob_flush(), yields some resemblance of my theme files. But the visual representation of my styles is vastly different.

    • This reply was modified 7 years, 4 months ago by jorisw.
    Plugin Author fkrauthan

    (@fkrauthan)

    Hey sorry for the late reply but I just came back from vacation. Glad you figured it out. Please take a look at the existing theme files (e.g. https://github.com/fkrauthan/wp-mpdf/blob/master/themes/default.php) as the export some more global options to further optimize and configure your PDF output.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use my theme files to build the template’ is closed to new replies.