Live data from Hacker News

URL to PDF Microservice

github.com

61–70 of 95 posts

Re: URL to PDF Microservice

#61
post #42

Earlier quoted context omitted.

I am not at a computer noe, so I can’t test it, but do you take redirects into account? I hope you are not just whitelisting the initial URL, but also any URL’s it redirects to. If you don’t already, you should probably just disable redirects in whatever library you use.

I gave this a thought for a moment. Since we're using a real browser, there are huge amount of different ways to get the browser display a file:// link. Redirect is one, window.location.href is another, etc. The service shouldn't be run publicly in the internet for real use cases. If you do, the server should be designed in a way that it's not dangerous if the web server user gets read access to file system. I added…

You are using Chrome headless therefore you can use group policy to add "file://" to the URL blacklist; see http://www.chromium.org/administrators/policy-list-3#URLBlac...

Re: URL to PDF Microservice

#62
post #60

I would like to adopt something like this, but there are some pretty normal table functions in our current print solution that I don't know how to support in HTML. E.g. on a multi-page invoice, show a sub-total row at the bottom of each page. Does anyone know how to create this kind of function?

IIRC you can solve that using CSS for print media.

The browser will display a different CSS to the printer, so to speak.

Re: URL to PDF Microservice

#63
post #60

I would like to adopt something like this, but there are some pretty normal table functions in our current print solution that I don't know how to support in HTML. E.g. on a multi-page invoice, show a sub-total row at the bottom of each page. Does anyone know how to create this kind of function?

I'd be interested in this as well. The industry standard, PrinceXML, has a huge licensing fee (currently $3800 per server), but it's also rock solid, handles modern CSS, and has hooks for adding things like headers and footers for pages and tables.

Re: URL to PDF Microservice

#64
post #60

I would like to adopt something like this, but there are some pretty normal table functions in our current print solution that I don't know how to support in HTML. E.g. on a multi-page invoice, show a sub-total row at the bottom of each page. Does anyone know how to create this kind of function?

Use a element (unless you're actually trying to show a sub-total of just the page you're looking at).

Re: URL to PDF Microservice

#65
post #62
post #60

I would like to adopt something like this, but there are some pretty normal table functions in our current print solution that I don't know how to support in HTML. E.g. on a multi-page invoice, show a sub-total row at the bottom of each page. Does anyone know how to create this kind of function?

IIRC you can solve that using CSS for print media. The browser will display a different CSS to the printer, so to speak.

Yes, and instead of px or em, you can use mm for css units (positioning, size, etc.).

Re: URL to PDF Microservice

#66
post #30

I am using PhantomJS for a similar project running on AWS Lambda - running into all sorts of rendering bugs / crashes. Wanted to make the switch to puppeteer, but as of now it requires a higher version of NodeJS than what Lambda supports. Was in the process of looking at Docker containers for my service, anyone have any thoughts on Heroku vs Docker?

We've been dealing with scale for over a year at https://www.prerender.cloud/docs/api if you want to try a hosted service:

https://service.prerender.cloud/screenshot/https://google.co...

https://service.prerender.cloud/pdf/https://google.com

Re: URL to PDF Microservice

#67

Earlier quoted context omitted.

This is just pedantic. Anything can be scalable using that definition. Heck, I could hire a 3rd world worker to manually draw the PDF's, scan them to PDF using a scanner, and put them on a server and it would "scale linearly with the amount of money I spend" on labor.

Redrawing the PDF's and scanning them would likely not scale linearly with the amount of money you spend on labor. Labor tends to have diminishing marginal returns. The cost of hiring two workers is more than double that of hiring one worker because there is additional complexity in coordinating the workers. Also, for the record, this comment I'm making right now is just pedantic.

As long as the workers do not need to coordinate, it should scale.

Round-robin those folks.

Re: URL to PDF Microservice

#68
post #42

Earlier quoted context omitted.

I am not at a computer noe, so I can’t test it, but do you take redirects into account? I hope you are not just whitelisting the initial URL, but also any URL’s it redirects to. If you don’t already, you should probably just disable redirects in whatever library you use.

I gave this a thought for a moment. Since we're using a real browser, there are huge amount of different ways to get the browser display a file:// link. Redirect is one, window.location.href is another, etc. The service shouldn't be run publicly in the internet for real use cases. If you do, the server should be designed in a way that it's not dangerous if the web server user gets read access to file system. I added…

By default: if Headless Chrome hits a redirect to a file:// it returns: net::ERR_UNSAFE_REDIRECT

window.location.href = 'file:///' will return console error: "Not allowed to load local resource"

Re: URL to PDF Microservice

#69
post #30

I am using PhantomJS for a similar project running on AWS Lambda - running into all sorts of rendering bugs / crashes. Wanted to make the switch to puppeteer, but as of now it requires a higher version of NodeJS than what Lambda supports. Was in the process of looking at Docker containers for my service, anyone have any thoughts on Heroku vs Docker?

Hey, I'd love to talk to you more about your issues with getting over to puppeteer. I'm working on a product that separates application infrastructure from Chrome as it's nightmare to try and scale with. I've written somewhat extensively about the deployment approaches here: https://hackernoon.com/more-than-you-want-to-know-about-head...

That was a great read!

Re: URL to PDF Microservice

#70
OT (maybe) Question: I've gotten more and more annoyed over the years as links are deleted/decay etc. Even more so recently. Is there a plug-in that makes a 'personal archive' or potentially on-sends the page to the Archive. It would be useful to be able to search/go back in my time-line to webpages even if they were just static pdf's.
Post reply on HN