idea-html2pdf
Advanced tools
Comparing version 2.1.6 to 2.1.7
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import * as Handlebars from 'handlebars'; | ||
@@ -34,3 +35,3 @@ import { Languages, SignedURL } from 'idea-toolbox'; | ||
*/ | ||
create(params: HTML2PDFCreateParameters): Promise<Uint8Array>; | ||
create(params: HTML2PDFCreateParameters): Promise<Buffer>; | ||
/** | ||
@@ -41,5 +42,5 @@ * Create a new PDF created by an HTML source. | ||
* @param params the parameters to create the PDF | ||
* @return the PDF data (buffer) | ||
* @return the PDF data (Buffer) | ||
*/ | ||
createViaS3Bucket(params: HTML2PDFCreateViaS3BucketParameters): Promise<any>; | ||
createViaS3Bucket(params: HTML2PDFCreateViaS3BucketParameters): Promise<Buffer>; | ||
/** | ||
@@ -46,0 +47,0 @@ * Create the signedURL to a new PDF created by an HTML source. |
@@ -129,3 +129,3 @@ "use strict"; | ||
const { Payload } = await lambda.send(command); | ||
return Payload; | ||
return Buffer.from(Buffer.from(Payload).toString(), 'base64'); | ||
} | ||
@@ -142,3 +142,3 @@ catch (err) { | ||
* @param params the parameters to create the PDF | ||
* @return the PDF data (buffer) | ||
* @return the PDF data (Buffer) | ||
*/ | ||
@@ -153,3 +153,3 @@ async createViaS3Bucket(params) { | ||
const { Payload } = await lambda.send(invokeCommand); | ||
const s3params = JSON.parse(Payload.transformToString()); | ||
const s3params = JSON.parse(Buffer.from(Payload).toString()); | ||
const getObjCommand = new client_s3_1.GetObjectCommand(s3params); | ||
@@ -171,6 +171,8 @@ const { Body } = await s3.send(getObjCommand); | ||
const pdfData = await this.create(params); | ||
console.log(pdfData); | ||
const Bucket = params.s3Bucket; | ||
const Key = params.s3Prefix.concat('/', Date.now().toString().concat(Math.random().toString(36).slice(2)), '.pdf'); | ||
const upload = new lib_storage_1.Upload({ client: s3, params: { Bucket, Key, Body: pdfData } }); | ||
const upload = new lib_storage_1.Upload({ | ||
client: s3, | ||
params: { Bucket, Key, Body: pdfData, ContentType: 'application/pdf' } | ||
}); | ||
await upload.done(); | ||
@@ -177,0 +179,0 @@ const getCommand = new client_s3_1.GetObjectCommand({ Bucket, Key }); |
{ | ||
"name": "idea-html2pdf", | ||
"version": "2.1.6", | ||
"version": "2.1.7", | ||
"description": "IDEA helper for generating a PDF from HTML contents", | ||
@@ -5,0 +5,0 @@ "engines": { |
27349
538