This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class HtmlToPdf extends Component { | |
convertHtmlToPdf(e) { | |
fetch('https://v2018.api2pdf.com/chrome/html', { | |
method: 'post', | |
headers: { | |
'Accept': 'application/json', | |
'Content-Type': 'application/json', | |
'Authorization': 'YOUR-API-KEY' //Get your API key from https://portal.api2pdf.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-2.2.4.js" integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=" | |
crossorigin="anonymous"></script> | |
<style> | |
body { | |
background: #20262E; | |
padding: 20px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html style="color:green;" lang="en"> | |
<head> | |
<link href="https://fonts.googleapis.com/css?family=Spicy+Rice" rel="stylesheet"> | |
</head> | |
<body> | |
<p style="font-family:Spicy Rice, cursive;">Example of a custom font from fonts.google.com</p> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<body> | |
<p>Hello World, no font family, defaults to Times New Roman</p> | |
<p style="font-family:Times New Roman;">Hello World, Times New Roman</p> | |
<p style="font-family:Arial;">Hello World, Arial</p> | |
<p style="font-family:Courier;">Hello World, Courier</p> | |
<p style="font-family:Verdana;">Hello World, Verdana</p> | |
<p style="font-family:Tahoma;">Hello World, Tahoma</p> | |
<p style="font-family:Arial Black;">Hello World, Arial Black</p> | |
<p style="font-family:Comic Sans MS;">Hello World, Comic Sans MS</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" | |
crossorigin="anonymous"> | |
<style> | |
@page { | |
@bottom-right { | |
content: counter(page) " of " counter(pages); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"html": "<p>Hello World</p>", | |
"inlinePdf": true, | |
"fileName": "test.pdf", | |
"options": { | |
"footerRight": "Page [page] of [topage]" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"html": "<p>Hello World</p>", | |
"inlinePdf": true, | |
"fileName": "test.pdf", | |
"options": { | |
"displayHeaderFooter": true, | |
"footerTemplate": "<div class=\"page-footer\" style=\"width:100%; text-align:right; font-size:12px;\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div>" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class=\"page-footer\" style=\"width:100%; text-align:right; font-size:12px;\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div style="page-break-before:always;"> | |
<p>YOUR CONTENT 1</p> | |
</div> | |
<div style="page-break-before:always;"> | |
<p>YOUR CONTENT 2</p> | |
</div> | |
<div style="page-break-before:always;"> | |
<p>YOUR CONTENT 3</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"> | |
</head> | |
<body> | |
<main role="main" class="container"> | |
<div class="row"> | |
<div class="col-8"> |
NewerOlder