-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove temporary file #44
Comments
Yes, we should probably provide it in this package. The html can be deleted right after and the pdf after the stream is read. Anybody is welcome to PR this. Right now you can use |
Thank you for your time on this PR. I reviewed your code and done some more thinking regarding this topic now. It looks to me that this type of solution is not safe in the edge cases. It can still be polluting the system with temporary files If the process fails in the middle of the conversion or if the temp file is for a moment blocked with something else. I'm sorry I gave wrong recommendation in my previous comment. At this moment I think it is better to create a temp directory inside the What you think? |
👍 on this, also i think that the default for the |
Sure. What if the entire process dies before the |
In this case reaper cleans up the tmp files after it starts again.
No. I believe phantomjs needs to store the pdf into file so we need tmp files. |
i have an idea to remove dependency of temporary files but when using the electron-pdf recipe 😆, i'm afraid that because the way of phantomjs works, this will not possible at least for now. |
It looks like phantomjs can read from stdin and write to stdout. That may be a way to remove the dependency on temp files. Could just pipe the html to the child process and capture the output in a stream. Thoughts? |
See the docs, you can only render to file We could possibly remove the temp files on html. However I was using stdio to pass html to phantomjs originally and it was indeterministicly cutting it. Environment variables could work here, but we need the temp files because of the pdf anyway. |
I forgot to note there are methods to render into memory However searching the phantomjs issues shows it is not in the 1.9 and probably not even in the latest release |
You can use render to output to stdout Then capture that in a stream for the pdf. |
@ianloverink yes, but it is not cross-platform, and windows support is a big concern for this package and other products built with it. there is other way to make it possible, using named pipes (windows has support for named pipes and seems like phantomjs supports writing the pdf to a named pipe), but the implementation will be more complex and likely would require to use some c/c++ dependency (like https://github.com/avz/node-mkfifo, which unfortunately doesn't support creating named pipes on windows) |
Seems to have support for windows here: |
seems like it could work (on windows, they remove the temp file and send it to stdout/stderr), but i'm not sure to use stdout/stderr as the default mechanism to transfer the pdf, i think that transfering big chunks of data (large pdf files) via stdout/stderr will not scale (but i could be wrong), using the disk is the most performant way IMO (I think this package scales very well, since it uses the disk to transfer the pdf between the node.js and phantomjs processes), also it will make the i'm 👎 on this, maybe it could be added as an option for the let's wait for @pofider 's comments. |
@pofider have you tried before to remove the temp file when the stream is closed or ended? ( that way we clean up temp files. i still think that using the |
initial step to get rid of temp files ->#49 |
To summary this.. 1 (stdout). Using stdout would need a performance comparison on linux. Windows benefit is that we don't have to deal with temp cleanup. The stdout approach would take time to implement. It gives more security for linux - the pdf file doesn't leak somewhere where it could be potentially seen by other process. 2 (stream events). Deleting temp files in stream events is implemented in both 3 (reap). Third option is to use I don't think we need to have a combination of 2 and 3 at once. I like 3 more since it is complete and proven solution. The option 1 sounds very promising. However it is not sure it will work as expected and it will take time to implement. As for me, I can quickly add option 3 with reaper. I don't have currently (next weeks) time to investigate the stdout option, but I can give hints as I've already tried it this morning. I'll wait for your opinions and then we can decide based on it. |
Actually the module create temporary file (html, and pdf) for the generation of the pdf.
Can the plugin remove them when the pdf is created (or in case of fail) ?
Thanks
The text was updated successfully, but these errors were encountered: