How to open html as pdf on the fly in browser

I have a html page. When user hits the url, the html should be rendered as pdf and opened in browser
How can we achieve that.

Any help as to how it can be achieved.


Why? That sounds like an odd thing to do. Anyhow, you can serve up PDFs on the web, so I suggest you just make it a PDF in the first place. E.g.

1 Like

Thanks @ralphm!

I can do that before, but how to do that?
How to make an html page with css as pdf is my question then?

I cannot change the layout, format or styling. But in the end, it needs to come up as pdf.

All you have to do it upload it to your website and link to it. When people click the link, the PDF will open in the browser, pretty much like any other web page.

Are you asking how to convert the HTML page to PDF? If so, the easiest way is probably to open the page in a browser, choose Print > Print to File and choose a PDF format.

I would have to ask, though, why you need to do this. HTML is the native format for web pages, and will be much more accessible on many more devices than a PDF page. If you explain your particular need, we may be able to suggest a better solution.


I’m assuming the question is about how to give access to a PDF online, but I could be wrong.

An HTML file will not be converted to a .pdf file so it can be rendered in a browser. That’s not what browsers do. A browser will open a .pdf file as a .pdf file if it has been optioned to do so. But a browser does not convert HTML to .pdf.

That makes no sense. Why not just prepare .pdfs to start with?

1 Like

Since this topic is in the HTML & CSS category I’m unclear what the goal is.

If it is to “have my entire website as PDF files instead of HTML pages” I guess it would be possible.

But it would require some complex server-side stuff to happen to do it, and as others have posted, wouldn’t make much sense to do.

But my opinion is based on my likely incorrect understanding of what the goal is.

@hybrisser can you explain why you want this to happen?


Most systems can let the browser save web pages as pdf through the “Print as file” tab in your print out dialog.

If you happen to use Firefox there are addons that can save web pages as pdf files, you can even edit the web page and preview it before saving as pdf or print out. There are probably similar addons for other browser.

The “Print-Edit” addon:

The “Save as PDF” addon:

The “Save as PDF” addon from uses their online service to convert web pages to pdf files.

What can be of interest if your question in your first post is still what you want, is that they also offer a free license to put a button on the pages you want your visitors to save as pdf files. Mind that it’s not free for a commercial site:

I myself use the “Print-Edit” addon on a regular basis to edit or remove parts of the layout before saving or printing.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.