在react js中保存pdf文件



我有以下代码在reactjs我想保存pdf文件,已经存在使用以下代码在哪里把pdf文件"报告"在doc。pdf文件被导入到下面的代码中,名称为Report。如何使用doc.save().

import React from 'react';
import { withRouter } from 'react-router-dom';
import { Button, Label, Form, Col, Row, Alert, Modal, Container, Card, CardImg, Dropdown, Table, InputGroup,FormControl} from 'react-bootstrap';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faFilter,faDownload,faUpload,faShare, faEye, faEyeSlash, faListCheck, faXmark, faPrint } from '@fortawesome/free-solid-svg-icons';
import jsPDF from 'jspdf'
import Report from '../../resources/Report.pdf';
class OnboardingGuide extends React.Component {
handleGetPDF  = () => {
let doc = new jsPDF('l', 'pt');
doc.save('Report11.pdf') // saves pdf 
}
render() {
return(   
<thead>
<tr>
<th>Onboarding Guide</th>
<th>PDF</th>  
</tr>
</thead> 
<tbody>

<tr>

<FontAwesomeIcon icon={faDownload} onClick={ this.handleGetPDF} style={{cursor: "pointer"}}/></td>


</tr>

</tbody>
)
}
}
export default withRouter(OnboardingGuide);

如果我没有错的话,您的工具jspdf使您能够生成PDF,但不是您想要的方式。因为它没有使用已经存在的pdf。

试着这样做。

最新更新