首页 文章

mPDF在Internet Explorer中不生成

提问于
浏览
0

我有以下代码 . 它在Chome和Firefox中生成PDF很好,但它拒绝在Internet Explorer中生成 . 我已经尝试将PDF写入文件,发送正确的PDF Headers ,然后将文件的内容回显到浏览器,这将再次在Chrome和Firefox中正常工作,但它仍然拒绝在IE中呈现 .

我错过了什么?

<?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;
?>

1 回答

  • 0

    最终这是不可能的 . 我不得不转向生成HTML页面 .

相关问题