dozabg1616 2016-06-20 04:13
浏览 125

如何修复:domPDF生成的输出结果?

Hi this is what I'm getting with the domPDF. Is my final result, but obviously I don't want that, I want my page printed in PDF.

I need the file get downloaded in the user browser, not in localhost.

enter image description here

This is my javascript:

$("#submit").click(function(){          
        $.post("converter/converter.php", {strHtml: $(".container-   fluid").html()}, function(data, status){
                alert("Data: " + data);
        });
    });

this is my php:

<?php
    require_once '../dompdf/autoload.inc.php';
    use Dompdf\Dompdf;

    $html = $_POST['strHtml'];

    $dompdf = new Dompdf();

    $dompdf->loadHtml($html);
    $dompdf->setPaper('A4', 'landscape');
    $dompdf->render();
    $dompdf->output('test.pdf', 'F');
 ?>

This is what I want to display in pdf :

enter image description here

  • 写回答

2条回答 默认 最新

  • doubi1928 2016-06-20 05:02
    关注

    If you want to save the generated pdf file to disk. You don't need file_put_content(). But you pass two parameters to the ->output() method, like this:

    $dompdf->output($path_to_new_file, 'F');
    
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料