Jonathon Klem
Jonathon Klem

Reputation: 358

mPDF Not Generating In Internet Explorer

I have the following code. It's generating PDFs fine in Chome and Firefox, but it refuses to generate in Internet explorer. I've tried writing the PDF out to a file, sending the proper PDF headers, and then echoing the contents of the file out to the browser and this again will work OK in Chrome and Firefox, but it still refuses to render in IE.

What am I missing?

<?php
    require_once('wp-blog-header.php');
    require_once('mpdf/mpdf.php');

    $pid = $_GET['product'];

    $args = array(
        'p'         => $pid,
        'post_type' => 'any');

    $query = new WP_Query($args);
    if (!$query->have_posts()) {
        die("Invalid Product");
    }

    if (has_post_thumbnail($_GET['product'])) {
        $image = wp_get_attachment_image_src(get_post_thumbnail_id($pid, 'single-post-thumbnail'));
        $image = $image[0];
    } else {
        $image = "<h1>NO IMAGE</h1>";
    }

    $query->the_post();

    $mpdf = new mPDF();

    ob_start();
?>
<html>
    <head>
        <title>Tear Sheet</title>
        <style>
            body, html {
                font-size: 20px;
                color: #777777;
                margin: 0px;
                padding: 0px;
                font-family: "Georgia";
            }
            #main-content {
                background: url('IP-Tearsheet-Background.jpg');
                /*width: 1530px;
                height: 1980px;*/
                width: 100%;
                height: 100%;
                background-size:100% 100%;
                display:block;
                position: absolute;
                left:0px;
                top:0px;
            }
            /*.attachment-full.wp-post-image {
                display:block;
                //margin:auto;
                position:absolute;
                top:120px;
                left:50%;
                margin-left:-100px; 
                padding-top:350px;
                max-width: 100px;
                width: 100px !important;
            }
            img {
                width: 100px !important;
            }*/
            #table-container {
                display:table;
                margin-top: 580px;
                position:relative;
                top:100px;
            }
            #style-number {
                display: table-cell;
                width: 563px;
            }
            #width {
                display: table-cell;
                width: 247px;
            }
            #depth {
                display: table-cell;
                width: 238px;
            }
            #height {
                width: 30px;
                display: table-cell;
                width: 190px;
            }
            #details {
                margin-top: 100px;
                margin-left: 80px;
                font-size:20px;
            }
        </style>
    </head>
    <body>
        <div id="main-content">
            <br><br><br><br><br>
            <table border=0 cellspacing=0 cellpadding=0>
                <tr><td width="190px">&nbsp;</td><td style="text-align: middle;"><?php the_post_thumbnail( array(400, 400) ); ?></td></tr>
            </table>
            <br><br><br><br><br>
            <?php //echo '<img src="' . get_the_post_thumbnail('full') . '" class="product-image">'; ?>
            <table border=0 cellspacing=0 cellpadding=0 style="margin-left: 87px;margin-top:70px">
                <tr>
                    <td style="width: 345px;"><?php echo get_post_meta($pid, '_sku', true); ?></td>
                    <td style="width: 150px;"><?php echo get_post_meta($pid, '_width', true); ?> in.</td>
                    <td style="width: 150px;"><?php echo get_post_meta($pid, '_length', true); ?> in.</td>
                    <td style="width: 190px;"><?php echo get_post_meta($pid, '_height', true); ?> in.</td>
                </tr>
            </table>
            <br>
            <!-- <div id="table-container">
                <div id="style-number">
                    <?php echo get_post_meta($pid, '_sku', true); ?> in.
                </div>
                <div id="width">
                    <?php echo get_post_meta($pid, '_width', true); ?> in.
                </div>
                <div id="depth">
                    <?php echo get_post_meta($pid, '_length', true); ?> in.
                </div>
                <div id="height">
                    <?php echo get_post_meta($pid, '_height', true); ?> in.
                </div>
            </div> -->
            <div id="details">
                Details
                <?php the_content(); ?>
            </div>
        </div>
    </body>
</html>
<?php
    $output = ob_get_clean();
    $mpdf->WriteHTML($output);

    $mpdf->Output();
    exit;
?>

Upvotes: 0

Views: 154

Answers (1)

Jonathon Klem
Jonathon Klem

Reputation: 358

In the end this wasn't possible. I had to move to generating an HTML page.

Upvotes: 0

Related Questions