node-native-printer icon indicating copy to clipboard operation
node-native-printer copied to clipboard

Image locks not released

Open juona opened this issue 5 years ago • 3 comments

Hello,

Many thanks for this lib, it worked out very well for me. However, there seems to be an issue : ]

Describe the bug I think there is a problem with how images are accessed.

To Reproduce Print an image, then go and try to delete it. It will not work, the file is EBUSY, locked by the node process.

Expected behavior I believe that the code places a lock on the file (https://github.com/MatteoMeil/node-native-printer/blob/master/lib/windows/src/windows_printer/Methods.cs#L267) and does not release it, even though the reference is good for garbage collection.

OS Windows 10

I haven't had a chance to try much else, only images on Windows 10.

juona avatar Dec 04 '19 21:12 juona

@juona I had the same issue, I forked this repo, made the necessary modifications to unlock the files and built a new dll for this, just finished testing on windows 10 and it works (I'm not a C# programmer so excuse the commits where I was attempting different solutions):

https://github.com/bennettstone/node-native-printer / https://github.com/bennettstone/node-native-printer/commit/d83959bb9815824bc280a58ee8dce970c22e6afc

I included it in my electronjs project by running:

npm install --save bennettstone/node-native-printer#d83959bb9815824bc280a58ee8dce970c22e6afc

bennettstone avatar Jan 12 '20 20:01 bennettstone

npm install --save bennettstone/node-native-printer#d83959bb9815824bc280a58ee8dce970c22e6afc

This solution works for me. Thanks a lot!!!

Allyday avatar Mar 12 '20 06:03 Allyday

@bennettstone It took me a while to come back to this. I can confirm that this does indeed work. I'd recommend raising a PR, however this lib does not seem to be actively maintained.

Thanks for your help!

juona avatar Oct 13 '20 08:10 juona