import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Button from 'react-bootstrap/Button';
import Table from 'react-bootstrap/Table';
import Modal from 'react-bootstrap/Modal';
import { BiPaperPlane, BiCloudDownload } from "react-icons/bi";
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf'
function GenerateInvoice() {
html2canvas(document.querySelector("#invoiceCapture")).then((canvas) => {
const imgData = canvas.toDataURL('image/png', 1.0);
const pdf = new jsPDF({
orientation: 'portrait',
unit: 'pt',
format: [612, 792]
});
pdf.internal.scaleFactor = 1;
const imgProps= pdf.getImageProperties(imgData);
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
pdf.save('invoice-001.pdf');
});
}
class InvoiceModal extends React.Component {
constructor(props) {
super(props);
}
render() {
return(
{this.props.info.billFrom||'John Uberbacher'}
Invoice #: {this.props.info.invoiceNumber||''}
Amount Due:
{this.props.currency} {this.props.total}
Billed to:
{this.props.info.billTo||''}
{this.props.info.billToAddress||''}
{this.props.info.billToEmail||''}
Billed From:
{this.props.info.billFrom||''}
{this.props.info.billFromAddress||''}
{this.props.info.billFromEmail||''}
Date Of Issue:
{this.props.info.dateOfIssue||''}
| QTY |
DESCRIPTION |
PRICE |
AMOUNT |
{this.props.items.map((item, i) => {
return (
|
{item.quantity}
|
{item.name} - {item.description}
|
{this.props.currency} {item.price} |
{this.props.currency} {item.price * item.quantity} |
);
})}
| |
|
|
|
SUBTOTAL |
{this.props.currency} {this.props.subTotal} |
{this.props.taxAmmount != 0.00 &&
|
TAX |
{this.props.currency} {this.props.taxAmmount} |
}
{this.props.discountAmmount != 0.00 &&
|
DISCOUNT |
{this.props.currency} {this.props.discountAmmount} |
}
|
TOTAL |
{this.props.currency} {this.props.total} |
{this.props.info.notes &&
{this.props.info.notes}
}
)
}
}
export default InvoiceModal;