ใครเคยใช้ html2canvas ช่วยทีค่ะ

เริ่มโดย ChilTunDer, 04 สิงหาคม 2018, 16:35:54

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

ChilTunDer

เราต้องการปริ้นหน้าเว็บโดยให้เอารูปมาด้วย แต่ลองแล้วมาเฉพาะข้อความค่ะ ตามโค้ดด้านล่าง ต้องแก้ไขในส่วนไหนค่ะ

<div id="head">
<table>
<tbody>
<td>
  <img src="http://www.pensacolastate.edu/wp-content/uploads/2018/01/Canvas-Logo.png" height="50"/>
  <div>
    <p>test1</p>
    <p>test2</p>
  </div>
</td>
<td>
  <img src="http://www.pensacolastate.edu/wp-content/uploads/2018/01/Canvas-Logo.png" height="50"/>
  <div>
    <p>test1</p>
    <p>test2</p>
  </div>
</td>
<td>
  <img src="http://www.pensacolastate.edu/wp-content/uploads/2018/01/Canvas-Logo.png" height="50"/>
  <div>
    <p>test1</p>
    <p>test2</p>
  </div>
</td>
</tbody>
</table>
</div>



* {
  padding: 0;
  margin: 0;
}
div{
  display: inline-block;
  vertical-align: middle;
  margin-left: 10px;
}


html2canvas($('#head'), {
                allowTaint: true,
                onrendered: function (canvas) {
var base64image = canvas.toDataURL("image/png");
                console.log(base64image);

                }
            });



เราใช้ library ของ http://html2canvas.hertzen.com/



Tutorcuu