使用jspdf和html2canvas库下载pdf会使pdf内容变得模糊

时间:2017-12-05 14:13:38

标签: javascript jquery jspdf html2canvas

当我使用jspdf和html2canvas库下载pdf时,pdf内容变得模糊。在这里,我想将html文件转换为pdf。图像质量和文本质量正在下降。

<div id="content" style="background-color: #ffffff;">

   <div class="container-fluid" style="color:black;">


<table style="margin-bottom: 0px;border-collapse:collapse;border: 1px solid black;" id="table-sm" class="table table-bordered  table-sm">

                    <tbody>
                    <tr >

                        <td class="color-blue-grey-lighter" colspan="3" style="border: 1px solid black ;"><center><img src="fb.png"></center></td>

                    </tr>

                    <tr>

                    </tbody></table>

                <table style="margin-top: 0px;border-collapse:collapse;border: 1px solid black;" id="table-sm" class="table table-bordered  table-sm">
                    <tbody>

                        <tr >
                        <td style="border: 1px solid black ;" class="color-blue-grey-lighter" colspan="2"><strong>DECLARATION: </strong><p style="color:black;">I hereby delare that the infomation furnished by me in the Registration/Application Form is correct and nothing has been concleaded.In case any information furnished by me is found to be false/incorrect/untrue then i shall be liable to civil/criminal prosecution and my claim to asmission/appointment/registraion/service in the Institute may be cancelled/terminated.</p></td>

                        </tr>

                    </tbody>
                </table>
</div>

</div>
<button id="cmd" style="float: right;" type="button" class="btn btn-danger">Download</button>

<script>
$('#cmd').click(function() {
  var options = {};
  var pdf = new jsPDF('p', 'pt', 'a4');
  <!--pdf.setTextColor(255,0,0);-->
  pdf.addHTML($("#content"), 15, 15, options, function() {
    pdf.save('pageContent.pdf');
  });
});

</script>

1 个答案:

答案 0 :(得分:0)

看看这个(github.com/niklasvh/html2canvas/pull/1087) https://github.com/niklasvh/html2canvas/pull/1087