doujiyun0041 2016-09-30 16:25
浏览 221

使用HTML字符串中的wkhtmltopdf导出为PDF

I have a website with HTML/CSS and a JavaScript generated inline datepicker. You can mark days in datepicker.

I want to export the whole content with the marks in datepicker as a PDF.

With Client-Side jsPDF and canvas2html I have a problem with position and sizes. I get partial content in the PDF only (begin or end from datepicker).

Now I try it with wkhtmltopdf.

I get the HTML with $("#datepicker").html() and send it to a PHP Script. It works with a test string, but I get a blank pdf when I use real data.

$.ajax({
  data: 'htmlstring=' + escape($("#datepicker").html()),
  url: 'http://example.com/htmltopdf.php',
  method: 'POST',
  success: function(msg) {
   alert(msg);
  }
});

<?php
  $htmlString = $_POST["htmlstring"];
  //$htmlString = rawurldecode($htmlString);
  exec('echo "<html><head></head><body>' . $htmlString . '</body></html>" | /usr/local/bin/wkhtmltopdf --encoding UTF-8 - export.pdf');
?>

I also like a different working solution.

  • 写回答

1条回答

  • doulian4762 2016-09-30 18:34
    关注
    data: {
       htmlstring: escape($("#datepicker").html())
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥50 成都蓉城足球俱乐部小程序抢票