chunyenHuang / hummusRecipe

A powerful PDF tool for NodeJS based on HummusJS.
https://hummus-recipe.s3.amazonaws.com/docs/Recipe.html
MIT License
339 stars 91 forks source link

can i use buffer instead of path #203

Open biloo-dev opened 3 years ago

biloo-dev commented 3 years ago

Hi everyone I have an image that received it from the server I don't want to save it to path Can I use buffer instead of path

let ImgBuffer = res.data
const pdfDoc = new HummusRecipe(input, output);
    pdfDoc
      .editPage(2)
      .image(ImgBuffer), 350, 660, {
        width: 200,
        keepAspectRatio: true,
      }) 
      .endPage()
      .endPDF(console.log);
hdiaz-nectia commented 3 years ago

I want to do the same but with the encrypt method:

let bufferPdf;
const pdfDoc = new HummusRecipe(filename);
pdfDoc
    .encrypt({
        userPassword: key,
        ownerPassword: key,
        userProtectionFlag: 4
    })
    .endPDF(buffer => {
        bufferPdf = buffer;
    });