- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个带图像的 html 表。当我尝试转换为 PDF 时,只有数据来了。图像未以 PDF 格式显示。
如何获取pdf格式的表格td图片?
契约(Contract)标题包含复选框图像。但不是以 pdf 格式提供吗?
我的pdf代码:
function fnExportDIVToPDF() {
var pdf = new jsPDF('l', 'pt', 'a2');
pdf.setFontSize(8);
source = $('#divReport')[0];
specialElementHandlers = {
'#bypassme': function (element, renderer) {
return true
}
};
margins = {
top: 30, bottom: 40, left: 10, width: 1300};
pdf.fromHTML(
source, margins.left, margins.top, {
'elementHandlers': specialElementHandlers},
function (dispose) {
pdf.save('Report.pdf');
}
, margins);
}
分区:
<div id="divReport">
<div width="100%">
<p><span id="oHeadingSummary" class="rptheader"></span></p>
</div>
<table class="table table-striped rpttable" border="1" cellspacing="0" id="oReportContractDetailsByCA" width="100%">
<colgroup>... <col width="10%">
</colgroup></table>
自动生成表格我添加了一张图片:
function GenerateTable(data) {
document.getElementById('divExport').style.display = "";
if (i == 0) {
$('#oReportContractDetailsByCA').append("<tr style='background-color:" + bkColor + ";'><td><img src='../../../_layouts/15/1033/IMAGES/eContracts/checked-checkbox-512.jpg'></img></td></tr>")
}
最佳答案
您可以使用 didDrawCell Hook 将任何内容添加到单元格。
https://codepen.io/someatoms/pen/vLYXWB
function generate() {
var doc = new jsPDF();
doc.autoTable({
html: '#mytable',
bodyStyles: {minCellHeight: 15},
didDrawCell: function(data) {
if (data.column.index === 5 && data.cell.section === 'body') {
var td = data.cell.raw;
// Assuming the td cells have an img element with a data url set (<td><img src="data:image/jpeg;base64,/9j/4AAQ..."></td>)
var img = td.getElementsByTagName('img')[0];
var dim = data.cell.height - data.cell.padding('vertical');
var textPos = data.cell.textPos;
doc.addImage(img.src, textPos.x, textPos.y, dim, dim);
}
}
});
doc.save("table.pdf");
}
关于jspdf - 如何使用 jsPDF 获取 PDF 中的表格行图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40465155/
我正在使用带有插件 jspdf-autotable 的 jspdf 来为一个非常宽的表格创建一个 pdf,有没有办法让表格/列数据自动适应任何页面大小? 我尝试了下面的代码溢出:'linebreak'
我的表有 13 列。如何为每列获得不同的宽度?我可以像这样给每个列宽吗? 样式:{溢出:'换行符',列宽:[100,80,80,70,80,80,70,70,70,70,60,80,100]}, 我的
如何使用jspdf和jspadf-autotable在PDF中实现嵌套表格?类似于下图的内容: 最佳答案 jspdf-autotable 中不支持嵌套表格,但您可以使用 didDrawCell Hoo
在 jsPDF 中使用 .cell 时如何删除填充? 我到处都看了,文档很模糊 this.pdf = new jsPDF(); this.pdf.cell(0, 0, 10, 10, "cell ce
表格插件 JsPDF-AutoTable: https://github.com/simonbengtsson/jsPDF-AutoTable 如何使页面横向与纵向相反?在文档中,它只是说“仅支持 p
是否可以添加 HyperLink在 jsPDF ? 这是我用于相同的代码。 var doc = new jsPDF('p', 'pt'); doc.fromHTML( 'Cl
我对 jsPDF autotable 有疑问。 我的代码: $('#printBtn').on('click', function() { var pdf = new jsPDF('p
我有自动表的问题。我的表由 thead、tbody 和 tfoot 组成。我的脚是我在每一列上的总值(value)。我能够生成 pdf,但 tfoot 或总页脚不断打印在每一页上。我在检查文档时使用
有人可以帮忙举一个为 jspdf-autotable 设置自定义字体的例子吗? 我尝试了以下 var doc = new jsPDF('p', 'pt'); doc.setFont("rotobo")
我有一个带图像的 html 表。当我尝试转换为 PDF 时,只有数据来了。图像未以 PDF 格式显示。 如何获取pdf格式的表格td图片? 契约(Contract)标题包含复选框图像。但不是以 pdf
我正在做的是使用 jsPDF 创建我生成的图形的 PDF。但是,我不确定如何包装标题(使用 text() 函数添加)。标题的长度因图形而异。目前,我的标题正在页面外运行。任何帮助,将不胜感激! 这是我
我正在使用img jsPDF AutoTable库从我的HTML表创建PDF文件,Everythink工作正常,PDF总是创建,但我对我的国家/地区典型的一些特殊字符有疑问。在我的 PDF 文件中,包
JsPdf-autoTable是一款非常棒的软件,并且非常简单就能让基础功能发挥作用。 现在我想在每个页面的顶部添加一个 Logo 和一些文本,并在每个页面上添加一个 page X of Y 页脚,但
我有一个用于保存 html 页面的按钮。当用户单击按钮时,我想触发 jsPDF 函数,但它返回“jspdf PubSub 错误”并且生成的 pdf 文件为空白。 var doc = new jsPD
我是使用 jsPDF 的新手,能够很好地生成普通 PDF,但是当我尝试应用外部 CSS 或普通样式背景颜色时,它没有任何效果。 我的 JSP 包括: 我正在使用下
我正在尝试将“页码 x of y”添加到使用 jspdf 和 jspdf-autotable 生成的 PDF 中。我使用了 jspdf-autotable 示例网站上的 Examples.js 文件中
我正在使用jspdf和jspdf-autotable将基于数据的表格导出为PDF。 有时,我的数据可能包含 DOM 元素,这些元素不由 jspdf-autotable 插件处理。在大多数情况下,DOM
我刚刚开始使用 jsPDF 和 AutoTable 插件,它几乎完美地满足了我们的使用需求。一个问题... 是否可以将列定义中的 dataKey 分配给映射到表的 JSON 中的嵌套属性? 我们有一个
我刚刚开始使用 jsPDF 和 AutoTable 插件,它几乎完美地满足了我们的使用需求。一个问题... 是否可以将列定义中的 dataKey 分配给映射到表的 JSON 中的嵌套属性? 我们有一个
我使用 Array.prototype.push() 创建了一个包含来自动态表的值的数组.然后像这样把它转换成pdf doc.autoTable(vHeader, vData, opt); doc.s
我是一名优秀的程序员,十分优秀!