doc.fromHTML 不是函数
doc.fromHTML is not a function
我正在尝试将 jspdf 与我的 React 应用程序一起使用,在我的文档和 jspdf 的类型中,我可以看到有一个名为 fromHTML 的函数。但是当我尝试调用函数时出现以下错误:
doc.fromHTML is not a function
有人可以帮我吗?
import { jsPDF } from 'jspdf'
const Prints = () => (
<div>
<h3>Time & Materials Statement of Work (SOW)</h3>
<h4>General Information</h4>
<table id='tab_customers' class='table table-striped'>
<colgroup>
<col span='1' />
<col span='1'/>
</colgroup>
<thead>
<tr class='warning'>
<th>SOW Creation Date</th>
<th>SOW Start Date</th>
<th>Project</th>
<th>Last Updated</th>
<th>SOW End Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dec 13, 2017</td>
<td>Jan 1, 2018</td>
<td>NM Connect - NMETNMCM</td>
<td>Dec 13, 2017</td>
<td>Dec 31, 2018</td>
</tr>
</tbody>
</table>
<p>
This is a Time and Materials Statement of Work between Northwestern Mutual
Life Insurance Company and Infosys with all general terms and conditions
as described in the current Master Agreement and its related documents
</p>
</div>
)
function generatePdf() {
const doc = new jsPDF( 'p', 'mm', 'a4' )
let index = 0
const htmlToConvert= renderToString(<Prints />)
doc.fromHTML(htmlToConvert)
doc.save('myPdf')
}
单击按钮时调用 generatePdf 函数
尝试将 doc.fromHTML 更改为 doc.html,如下所示:
function generatePdf() {
const doc = new jsPDF( 'p', 'mm', 'a4' )
let index = 0
const htmlToConvert= renderToString(<Prints />)
doc.html(htmlToConvert, {
callback: function (doc) {
doc.save();
}
});
}
这对你有帮助吗?
我正在尝试将 jspdf 与我的 React 应用程序一起使用,在我的文档和 jspdf 的类型中,我可以看到有一个名为 fromHTML 的函数。但是当我尝试调用函数时出现以下错误:
doc.fromHTML is not a function
有人可以帮我吗?
import { jsPDF } from 'jspdf'
const Prints = () => (
<div>
<h3>Time & Materials Statement of Work (SOW)</h3>
<h4>General Information</h4>
<table id='tab_customers' class='table table-striped'>
<colgroup>
<col span='1' />
<col span='1'/>
</colgroup>
<thead>
<tr class='warning'>
<th>SOW Creation Date</th>
<th>SOW Start Date</th>
<th>Project</th>
<th>Last Updated</th>
<th>SOW End Date</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dec 13, 2017</td>
<td>Jan 1, 2018</td>
<td>NM Connect - NMETNMCM</td>
<td>Dec 13, 2017</td>
<td>Dec 31, 2018</td>
</tr>
</tbody>
</table>
<p>
This is a Time and Materials Statement of Work between Northwestern Mutual
Life Insurance Company and Infosys with all general terms and conditions
as described in the current Master Agreement and its related documents
</p>
</div>
)
function generatePdf() {
const doc = new jsPDF( 'p', 'mm', 'a4' )
let index = 0
const htmlToConvert= renderToString(<Prints />)
doc.fromHTML(htmlToConvert)
doc.save('myPdf')
}
单击按钮时调用 generatePdf 函数
尝试将 doc.fromHTML 更改为 doc.html,如下所示:
function generatePdf() {
const doc = new jsPDF( 'p', 'mm', 'a4' )
let index = 0
const htmlToConvert= renderToString(<Prints />)
doc.html(htmlToConvert, {
callback: function (doc) {
doc.save();
}
});
}
这对你有帮助吗?