问题描述
我正在尝试使用 react jspdf 生成 pdf。这是我的代码。
>>> v.agg([np.mean,lambda x: np.mean(x)])
ValueError: cannot combine transform and aggregation operations
<div>
<div id="pdfGeneration">
<h1>This will generate a pdf</h1>
</div>
<button onClick={this.documentprint} >
Generate Pdf </button>
</div>
它工作正常并生成pdf。 但我不想在我的组件中显示特定 id 的数据,我必须为该特定 id 创建一个 pdf 。 我尝试使用样式标签 display:none 对于特定的 id 在这种情况下它在 pdf 中显示为空。 我也试过这种方法
public documentprint = (e) => {
e.preventDefault();
var blob;
const myinput = document.getElementById('pdfGeneration');
html2canvas(myinput)
.then((canvas) => {
var imgWidth = 200;
var pageHeight = 290;
var imgHeight = canvas.height * imgWidth / canvas.width;
var heightLeft = imgHeight;
const imgData = canvas.toDataURL('image/png');
const mynewpdf = new jsPDF('p','mm','a4');
var position = 0;
mynewpdf.text("testing",20,20)
mynewpdf.addImage(imgData,'JPEG',5,position,imgWidth,imgHeight);
blob = mynewpdf.output('blob');
})
}
''`
public createPdfData = () => {
return (
<div id="pdfGeneration">
<h1>This will generate a pdf</h1>
</div>
)
}
public documentprint = (e) => {
e.preventDefault();
var blob;
const myinput:any = this.createPdfData();
html2canvas(myinput)
.then((canvas) => {
var imgWidth = 200;
var pageHeight = 290;
var imgHeight = canvas.height * imgWidth / canvas.width;
var heightLeft = imgHeight;
const imgData = canvas.toDataURL('image/png');
const mynewpdf = new jsPDF('p',imgHeight);
blob = mynewpdf.output('blob');
})
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)