galkahana / HummusJS

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

hummus.createReader can't release resource in Win 32 #275

Open hl-a-k opened 6 years ago

hl-a-k commented 6 years ago

In Win 32, I use hummus.createReader to create a reader.

And then I want to delete the file, but I found I can't do it, because reader don't release resource. The reader don't have end() method.

fxpopp commented 6 years ago

I have the same problem using Windows 7: hummus.createReader(pathToFile) blocks the file it reads How can it be 'closed' to move/delete/update the initial PDF file?

There are no problems on a mac so it may be specific windows problem

hl-a-k commented 6 years ago

please refer https://github.com/galkahana/HummusJS/pull/276

galkahana commented 6 years ago

that's cause win32 blocks other file pointers if ones opened for reading. you can either:

  1. scope out pdfreader
  2. use PDFRStreamForFile as source for pdfReader, which you can then close with its own method (.end)
hl-a-k commented 6 years ago

Thank you, it is a better way.

const inStream = new hummus.PDFRStreamForFile(f1);
  var input = hummus.createReader(inStream);
....
  inStream.close()

This Library is wonderful, but lack demo and doc.

galkahana commented 6 years ago

Oh i defo second that