Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging QR Image with Base64 encoded PDF #790

Open
umashankarsharma opened this issue Mar 14, 2018 · 3 comments
Open

Merging QR Image with Base64 encoded PDF #790

umashankarsharma opened this issue Mar 14, 2018 · 3 comments

Comments

@umashankarsharma
Copy link

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);
     });
@sboudouk
Copy link

sboudouk commented Sep 8, 2018

Same for me here. Did you managed to solve this ?

@umashankarsharma
Copy link
Author

Yes I did. I will post the solution.

@dimassm11
Copy link

good day, promised to write a solution.
the problem is relevant enough for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants