node-pdfkit

Generate pdf file using pdfkit and send it to browser in nodejs-expressjs

半城伤御伤魂 提交于 2019-12-04 16:01:30
问题 I am using pdfkit to generate pdf file and i want to send this pdf file to browser. But i am getting message "TypeError: listener must be a function", Also, file is getting generate in my parent directory which i don't want. Can anyone explain me how to generate pdf file and send it to browser without storing it at parent directory? I am using expressjs here. My code var PDFDocument = require('pdfkit'); var fs=require('fs'); doc = new PDFDocument(); doc.moveTo(300, 75) .lineTo(373, 301)

Serve dynamically generated PDF with remote images in Node.js

喜你入骨 提交于 2019-12-04 09:34:00
问题 I'm trying to create a Node server that generates a PDF on-the-fly using PDFKit. The PDF is generated based on parameters from a POST request (via Express). One of the parameters specifies an image URL, which the server downloads and injects into the PDF. Right now, I have the following structure: // Get dependencies var express = require('express'), http = require('http'), fs = require('fs'), pdfDocument = require('pdfkit'); // Get express started. var app = express(); // Use JSON in POST

Generate pdf file using pdfkit and send it to browser in nodejs-expressjs

夙愿已清 提交于 2019-12-03 10:02:40
I am using pdfkit to generate pdf file and i want to send this pdf file to browser. But i am getting message "TypeError: listener must be a function", Also, file is getting generate in my parent directory which i don't want. Can anyone explain me how to generate pdf file and send it to browser without storing it at parent directory? I am using expressjs here. My code var PDFDocument = require('pdfkit'); var fs=require('fs'); doc = new PDFDocument(); doc.moveTo(300, 75) .lineTo(373, 301) .lineTo(181, 161) .lineTo(419, 161) .lineTo(227, 301) .fill('red', 'even-odd'); var loremIpsum = 'Lorem

Upload pdf generated to AWS S3 using nodejs aws sdk

末鹿安然 提交于 2019-12-01 04:48:22
I am using pdfkit to generate a pdf with some custom content and then sending it to an AWS S3 bucket. While if I generate the file as a whole and upload it works perfectly, however, if I want to stream the generated file probably as an octet stream I am not able to find any relevant pointers. I am looking for a nodejs solution (or suggestion). Shivendra Soni I'll try to be precise here. I will not be covering usage of pdfKit 's nodejs sdk in much detail. IF you want your generated pdf as a file. var PDFDocument = require('pdfkit'); // Create a document doc = new PDFDocument(); // Pipe it's

How to pipe a stream using pdfkit with node js

耗尽温柔 提交于 2019-11-29 07:42:49
Before PDFkit 0.5 - the following worked for me (generating a pdf via pdfkit/printing via ipp to CUPS): var ipp = require("ipp"); var PDFDocument = require("pdfkit"); var doc = new PDFDocument; doc.text("Hello World"); doc.output(function(pdf)){ var printer = ipp.Printer("http://127.0.0.1:631/printers/1"); var file = { "operation-attributes-tag":{ "requesting-user-name": "User", "job-name": "Print Job", "document-format": "application/pdf" }, data: new Buffer(pdf, "binary") }; printer.execute("Print-Job", file, function (err, res) { console.log("Printed: "+res.statusCode); }); } As of PDFkit 0

How to pipe a stream using pdfkit with node js

China☆狼群 提交于 2019-11-28 01:14:29
问题 Before PDFkit 0.5 - the following worked for me (generating a pdf via pdfkit/printing via ipp to CUPS): var ipp = require("ipp"); var PDFDocument = require("pdfkit"); var doc = new PDFDocument; doc.text("Hello World"); doc.output(function(pdf)){ var printer = ipp.Printer("http://127.0.0.1:631/printers/1"); var file = { "operation-attributes-tag":{ "requesting-user-name": "User", "job-name": "Print Job", "document-format": "application/pdf" }, data: new Buffer(pdf, "binary") }; printer.execute

Set the default save as name for a an <embed> or <iframe> that uses a Blob

百般思念 提交于 2019-11-26 11:39:49
问题 I am generating a PDF in the browser using PDFKit (without node) and displaying it an iframe or an embed tag via the src attribute. The generated blob URL is some kind of UUID. So the overall page looks like: <embed src=\"blob:http://localhost/eeaabb...\"/> The PDF appears fine, but when I click the Download link in Chrome, the default file name is the UUID. In FireFox, it is just \"document.pdf\". If this were a server-generated PDF I would use Content-Disposition and/or manipulate the URL