4

I'm modifying a pdf using the code below but struggling with how to create a buffer that can then be used as an email attachment without writing anything to disk.

I'm finding it hard to work out from the documentation.

    var pdfWriter = hummus.createWriterToModify(__dirname + '/voucher.pdf', needToCreateBuffer);

    var pageModifier = new hummus.PDFPageModifier(pdfWriter, 0);
    var fontOswald = pdfWriter.getFontForFile('.fonts/Oswald-Bold.ttf');
    pageModifier.startContext()
        .getContext()
        .writeText(
            '£100',
            296, 105, {
                font: fontOswald,
                size: 70,
                colorspace: 'gray',
                color: 0x00
            }
        ).writeText(
            'CODE: GHGJHJHH',
            296, 80, {
                font: fontOswald,
                size: 18,
                colorspace: 'gray',
                color: 0x00
            }
        );
    pageModifier.endContext().writePage();
    pdfWriter.end();
dottodot
  • 1,479
  • 1
  • 16
  • 24
  • 1
    Were you able to find a solution to you problem? Can you shed some light on how you solved it? – PBandJ Jan 31 '17 at 20:26
  • @dottodot did you manage to solve your problem ? I am facing the same issue – TSR Sep 16 '19 at 12:11

1 Answers1

0

you can take look here. use streams creating buffer.

James Yang
  • 19
  • 3