1
我有一個網頁,我希望打印一些HTML。 爲此,我使用html2canvas
和jsPDF
。從html導出圖像到jsPDF
我遇到的問題是它不打印HTML中顯示的圖像。
我的HTML和CSS如下所示(complete code in fiddle):
.handsomeHtml {
background: red;
}
.crazyFrog {
background: url('http://e-cdn-images.deezer.com/images/artist/01eb92fc47bb8fb09adea9f763bb1c50/500x500.jpg');
width: 500px;
height: 500px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js">
</script>
<div id="someHtml" class="handsomeHtml">
Hello, handsome HTML
<br>
<img class="crazyFrog"></img>
</div>
<button id="savePDFbutton" onclick="savePDF()">
save pdf
</button>
預期結果:
實際PDF結果
謝謝,實際工作,但恐怕我不能一切轉換爲base64 – methgaard