node-html-pdf | This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to h | Document Editor library
kandi X-RAY | node-html-pdf Summary
kandi X-RAY | node-html-pdf Summary
:page_facing_up: Html to pdf converter in nodejs. It spawns a phantomjs process and passes the pdf as buffer or as filename.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Defines the paper size
node-html-pdf Key Features
node-html-pdf Examples and Code Snippets
npm install -g html-pdf
npm link html-pdf
npm link phantomjs-prebuilt
npm i html-pdf
let fname = "labelPrint-" + Date.now() + ".pdf" (THIS WAS MY USE-CASE)
var pdf = require("html-pdf");
var html = some html code;
pdf.create(html).toFile(fname, function(err, aa) {
if (err) ret
Community Discussions
Trending Discussions on node-html-pdf
QUESTION
I'm using node-html-pdf library to render an html page into a PDF on Node.js using Heroku. I'm facing an issue when using a custom system font Open Sans Condensed. I couldn't use the web font cause each character is being rendered as an svg, resulting in 10 times the size, so I installed the font locally (as a font on Mac and in the .fonts directory on Heroku). The problem is that both fonts on the Mac and Heroku are stretched out and not condensed. When rendering the html in a local browser, the font is rendered properly, but when passed through html-pdf, the fonts are stretched.
This is a sample css being used
...ANSWER
Answered 2018-Jan-06 at 14:08So apparently, the issue was that the font wasn't supported natively on Heroku or any other Linux-based server expect for Mac. This results in the font being drawn out by the framework, or the incorrect font is shown. Unfortunately, there was no solution to this expect to choose a different font or set up a Mac server and use that one to generate the PDF.
QUESTION
This is a plunker link. I run pdfSample.js
using node, pdfsample.html
is actual data to convert into pdf and generatepdf.html
is used to fetch it .
When i run it, it shows me an error Failed to load Pdf Document
. I reffered this sample. I am not getting any issue why it is not working?
ANSWER
Answered 2017-Dec-15 at 12:31You need to create the blob to the actual data not the response object.
You need new Blob([response.data], {type: 'application/pdf'})
But make sure that when you hit http://localhost:8081/api/printpdf1
you get the pdf and not an error.
QUESTION
I'm looking to render a pdf version of a webpage directly to the browser using express. Something like express.render() only render the page as pdf
I have found a module that will convert HTML or a URL to a pdf
https://github.com/marcbachmann/node-html-pdf
What i need to know is how can I use the response from that libary directly in a HTTP route handler to respond to requests with the PDF, I would prefer not to store the PDF, I just want to render it on the fly, and return it as a buffer or a stream to the browser
This is the basic API the module provides:
...ANSWER
Answered 2017-Apr-17 at 18:20This is quite easy to do in Node just using streams. The primary reason to use a stream over a Buffer
is that a stream doesn't need to keep all of its data in memory like a Buffer
does. Instead it can provide the data as needed to the reader or writer. This means that it is lightweight and will be better for performance in regards to latency and throughput.
In your case, you just want to pipe()
the contents of the stream directly to your res
object.
QUESTION
I am trying to convert HTML into a PDF, but the HTML is generated dynamically and never actually served up. I've been using node-html-pdf but it has some issues I've found difficult to overcome (known, long-standing bugs).
I thought I'd give wkhtmltopdf (via node-wkhtmltopdf) a try, but it expects a URL.
My current thought (which isn't great) is to expose the HTML via express since I'm already exposing a REST API with this server. While doing this isn't rocket science, it seems pretty complicated to just hand something content from memory.
Does anyone have a good pattern for using wkhtmltopdf from node with HTML held in memory?
...ANSWER
Answered 2017-Mar-03 at 19:10Apparently there are two npm packages for this. If you google 'node wkhtmltopdf' you are likely to run into this one first: node-wkhtmltopdf
...but if you look further you'll find: wkhtmltopdf which is seems more actively maintained and has documentation explaining how to use it directly, as mentioned by @Ben Fortune in the comments above.
Using the correct package, it seems well explained how to use HTML directly.
QUESTION
In my node/express app I create a pdf file with node-html-pdf:
...ANSWER
Answered 2017-Feb-23 at 12:45I have found a solution: You need to import ResponseContentType from @angular/http and change the response content type from json (Standard) to array buffer.
Edited code:
Backend node/express
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install node-html-pdf
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page