Comments (8)
My bad, fixed it you can close it.
from aws-lambda-wkhtmltopdf.
@ashish314 I'm having the same problem - how did you fix it??
Jon5
Nevermind - for those interested please see closed issue #4
from aws-lambda-wkhtmltopdf.
@Jonlee2001
In Index.js there seems to be wrong usage of wkhtmltopdf, use it as shown below
readStream = wkhtmltopdf(string,{optionsHere});
Means instead of callback it returns a readStream.
from aws-lambda-wkhtmltopdf.
Any idea how to solve this error?
from aws-lambda-wkhtmltopdf.
@rikee312
i have already mentioned the fix in my previous comment that fi works for me.
My previous comment below
In Index.js there seems to be wrong usage of wkhtmltopdf, use it as shown below
readStream = wkhtmltopdf(string,{optionsHere});
Means instead of callback it returns a readStream.
from aws-lambda-wkhtmltopdf.
@ashish314 ya it works
from aws-lambda-wkhtmltopdf.
@ashish314 @rikee312
Can either of you please provide example code that you got working with readStream = wkhtmltopdf(string,{optionsHere});
. I am running into the same issue and struggling with the correct usage of wkhtmltopdf in this context.
Thank you.
from aws-lambda-wkhtmltopdf.
'use strict';
process.env['PATH'] =
process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT'];
const wkhtmltopdf = require('wkhtmltopdf');
const MemoryStream = require('memorystream');
const { createResponse } = require('../utils/create-response');
module.exports.index = (event, context, callback) => {
let content = JSON.parse(event.body);
let html = content.html;
var memStream = new MemoryStream();
var html_utf8 = new Buffer(html, 'base64').toString('utf8');
const options = {
pageSize: 'letter'
};
wkhtmltopdf(html_utf8, options, function(code, signal) {
callback(
null,
createResponse(200, { pdf_base64: memStream.read().toString('base64') })
);
}).pipe(memStream);
};
this is the working code for me.
from aws-lambda-wkhtmltopdf.
Related Issues (11)
- Exported PDF file has error. HOT 5
- How do you declare the options to lambda function to be used
- UTF-8 doesn't seem to be working HOT 1
- How to test with a POST request? HOT 1
- Error handling? HOT 1
- "errorMessage": "Cannot find module '/var/task/index'" HOT 2
- Problem when unzipping and zipping again HOT 2
- Cannot read property 'toString' of null HOT 1
- Mobile Browsers Issue HOT 1
- compiling node_modules
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-wkhtmltopdf.