galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.15k stars 170 forks source link

How to know success/error ending? #164

Closed overflowz closed 7 years ago

overflowz commented 7 years ago

Hi, I'm trying to append pdf pages from another pdf (appendPDFPagesFromPDF).

I'm using following code (basic):

const hummus = require('hummus');

async function appendPages() {
  // can also return new Promise().
  const pdfWriter = hummus.createWriter('test.pdf');

  pdfWriter.appendPDFPagesFromPDF('append.pdf', {
    type: hummus.eRangeTypeSpecific,
    specificRanges: [[0, 0], [3, 3]]
  });

  pdfWriter.end();
  return true;
};

appendPages().then(() => { console.log('success') }).catch((err) => { console.error(err) });

When I saw the source, seems .end() is asynchronous.

So, how can I know that it ended up successfully or it had an error while doing it? Isn't there any callbacks to check? Also, do I have to cleanup it as well? If so, how to?

galkahana commented 7 years ago

all hummus methods are sync. so no need to worry about that.

overflowz commented 7 years ago

oh, thanks!