pofider / phantom-html-to-pdf

Highly scalable html to pdf conversion using phantom workers
MIT License
159 stars 33 forks source link

remove pdf temp file #49

Open bjrmatos opened 7 years ago

bjrmatos commented 7 years ago

this PR implements what i say in this issue.

for now, i've only removed the temporal pdf file (since it is the file that causes more troubles and the most important part of this module), we can discuss if we should remove the others files (templates) here, or after rendering, or implement other technique for template sharing, personally i would vote for the remove other files after rendering.

IMPORTANT NOTE: the temp pdf file is only removed if the user has been consumed the file, if the file it is not consumed, the pdf file will stay on disk, let me know if you would like me to implement the remove of the file even if it is not consumed (after conversion's callback execution), i have not do this because maybe there are edge cases when the pdf stream is used after the conversion's callback execution, but we can add to docs that we always clean up the pdf file, so the user will know that it has to consume the file in conversion's callback, not later because it will be removed.

bjrmatos commented 7 years ago

i've ended up implementing the remove of the file even when is not consumed, let me know what you think.

pofider commented 7 years ago

Thank you for this very nice implementation. I'm not very good in node.js streams so it is hard for me to give some valuable comments. I've summarized approaches for dealing with temp files here, so we can choose what will be implemented or merged

https://github.com/pofider/phantom-html-to-pdf/issues/44#issuecomment-272849974

peterdeme commented 6 years ago

What's the state of this?