Giter Site home page Giter Site logo

Not working about aws-lambda-wkhtmltopdf HOT 8 CLOSED

jblotus avatar jblotus commented on May 12, 2024
Not working

from aws-lambda-wkhtmltopdf.

Comments (8)

ashish314 avatar ashish314 commented on May 12, 2024

My bad, fixed it you can close it.

from aws-lambda-wkhtmltopdf.

Jonlee2001 avatar Jonlee2001 commented on May 12, 2024

@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.

ashish314 avatar ashish314 commented on May 12, 2024

@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.

sakadoddle avatar sakadoddle commented on May 12, 2024

Any idea how to solve this error?

from aws-lambda-wkhtmltopdf.

ashish314 avatar ashish314 commented on May 12, 2024

@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.

sakadoddle avatar sakadoddle commented on May 12, 2024

@ashish314 ya it works

from aws-lambda-wkhtmltopdf.

auvenshinec avatar auvenshinec commented on May 12, 2024

@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.

sakadoddle avatar sakadoddle commented on May 12, 2024

@auvenshinec

'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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.