This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Accessing end event on convertHtml

dooburt wrote on 2015-07-06:
Hello there,

I'm trying to access the end event (using Node) of the convertHtml method in a promise, I tried this:-

var client = new pdf.Pdfcrowd(username, apikey);
client.convertHtml(html, {
            pdf: function(rstream) {
                rstream.on('end', function() {
                    pdf.saveToFile(path);
                    resolve();
                });
            }
        }, a4);



But that doesn't work -- the PDF doesn't get generated (though curiously my API tokens goes down!). Basically, I want to resolve the promise/call a callback when I know the PDF has been generated and saved. Can anyone help?

Many thanks :)
dooburt wrote on 2015-07-07:
I solve this in the end with the following:

http://stackoverflow.com/questions/31255341/accessing-end-event-in-pdfcrowds-savetofile-method-in-node/31266730#31266730

I hope it helps anyone else experiencing the same problem. Props to other forum user 'trav' for his request for accessing the raw PDF data was what lead me on my way and his code was vital to put the chunks back together. Thanks trav.