我想在PDF页面上精确打印PDF格式的详细信息 我正在使用jsPDF将详细信息打印到PDF上 这是我的代码:
var pdf = new jsPDF('p', 'pt', 'a4');
var source = $('#mymy')[0];
var specialElementHandlers = {
// element with id of "bypass" - jQuery style selector
'#bypassme': function(element, renderer){
// true = "handled elsewhere, bypass text extraction"
return true
}
}
var margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
pdf.fromHTML(source, margins.left, margins.top, {
'width': margins.width // max width of content on PDF
, 'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
},
margins
)
Html代码:
<div class="form-group" id="mymy">
<ul ng-repeat="sec in abc" class="media-list tab-pane fade in active" style="border-style: solid;">
<ul ng-repeat="k in sec.usertype" ng-if="secs(k._id)">
<div class="panel panel-primary">
<div class="panel-heading">{{k.sec_name}}</div>
<div class="panel-body">
<ul ng-repeat="l in k.keywords">
<div class="row" name="options" id="{{k._id}}" ng-if="check(l._id)">
<div class="col-sm-5"> <img src="/client/app/images/t.png" width="20" height="15"><b>{{l.keyword}}</b></div>
<div class="col-sm-5"> <p>{{l.description}}</p></div>
</div>
</ul>
</div>
</div>
</ul>
</ul>
</div>
我希望在PDF上打印精确的页面 我不熟悉jsPDF。
答案 0 :(得分:1)
我知道它很旧,但是ng-if正在破坏Dom,因此您必须在脚本中构建pdf,而不要使用pdf.fromHtml例如dom元素。