Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
HTML to PDF with ReactJS
import React, { Component } from 'react';
class HtmlToPdf extends Component {
convertHtmlToPdf(e) {
fetch('', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'YOUR-API-KEY' //Get your API key from
body: JSON.stringify({html: '<p>hello world from reactjs</p>', inlinePdf: true, fileName: 'test.pdf' })
.then(res => console.log(res.pdf));
render() {
return (
<div className="App">
<button onClick={this.convertHtmlToPdf.bind(this)}>Generate Pdf</button>
export default HtmlToPdf;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.