Rendering react as pdf is generally a pain, but there is a way around it using canvas.
The idea is to convert : HTML -> Canvas -> PNG (or JPEG) -> PDF
To achieve the above, you'll need :
import React, {Component, PropTypes} from 'react';_x000D_
_x000D_
// download html2canvas and jsPDF and save the files in app/ext, or somewhere else_x000D_
// the built versions are directly consumable_x000D_
// import {html2canvas, jsPDF} from 'app/ext';_x000D_
_x000D_
_x000D_
export default class Export extends Component {_x000D_
constructor(props) {_x000D_
super(props);_x000D_
}_x000D_
_x000D_
printDocument() {_x000D_
const input = document.getElementById('divToPrint');_x000D_
html2canvas(input)_x000D_
.then((canvas) => {_x000D_
const imgData = canvas.toDataURL('image/png');_x000D_
const pdf = new jsPDF();_x000D_
pdf.addImage(imgData, 'JPEG', 0, 0);_x000D_
// pdf.output('dataurlnewwindow');_x000D_
pdf.save("download.pdf");_x000D_
})_x000D_
;_x000D_
}_x000D_
_x000D_
render() {_x000D_
return (<div>_x000D_
<div className="mb5">_x000D_
<button onClick={this.printDocument}>Print</button>_x000D_
</div>_x000D_
<div id="divToPrint" className="mt4" {...css({_x000D_
backgroundColor: '#f5f5f5',_x000D_
width: '210mm',_x000D_
minHeight: '297mm',_x000D_
marginLeft: 'auto',_x000D_
marginRight: 'auto'_x000D_
})}>_x000D_
<div>Note: Here the dimensions of div are same as A4</div> _x000D_
<div>You Can add any component here</div>_x000D_
</div>_x000D_
</div>);_x000D_
}_x000D_
}
_x000D_
The snippet will not work here because the required files are not imported.
An alternate approach is being used in this answer, where the middle steps are dropped and you can simply convert from HTML to PDF. There is an option to do this in the jsPDF documentation as well, but from personal observation, I feel that better accuracy is achieved when dom is converted into png first.
Update 0: September 14, 2018
The text on the pdfs created by this approach will not be selectable. If that's a requirement, you might find this article helpful.