Skip to content

Merging QR Image with Base64 encoded PDF #790

@umashankarsharma

Description

@umashankarsharma

Hi ,

I have PDF in base 64 encoded form. I want to edit and add an QR image to it using PDF kit.

Somehow when i try to merge the streams the content fails . Below is the code.

var base64 = require('base64-stream');
var PDFDocument = require('pdfkit');

    var doc = new PDFDocument ();

    doc.image('test.jpeg', {
            fit: [250, 300],
            align: 'center',
            valign: 'center'
    });

    var finalString = ''; // contains the base64 string
    var stream = doc.pipe(base64.encode());
    doc.end();

    var finalString = '';

    stream.on('data', function(chunk) {
            finalString += chunk;});

    stream.on('end', function() {
     // the stream is at its end, so push the resulting base64 string to the response
            read.writeFileSync('./report.pdf', finalString);
     });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions