wubzz / pdf-merge

Merge multiple PDF Files into a single PDF document
127 stars 32 forks source link

is it possible to make it synchronous? #19

Closed pwong2 closed 7 years ago

pwong2 commented 7 years ago

Hi @wubzz I know this is not an issue in pdf-merge, I'm new in node.js and I need your help maybe you already tried on it, I want to know how this method can be synchronous? the file must be merged first before it return the response 200.

PDFMerge(pdfFiles, { output: filepath, libPath: libPath })

.then(() => { res.writeHead(200); res.end(); });

thanks in advance

wubzz commented 7 years ago

@pwong2 Why do you want to make it synchronous?

Node 8 introduces a nice syntax

try {
    const mergedPDFBuffer = await PDFMerge(pdfFiles);

    res.writeHead(200);
    res.end();
} catch(error) {
    //Error handler
}
wubzz commented 7 years ago

No reply in two days, closing. Reopen if this is still an issue.