Overview
UniHTML converts HTML to PDF, and injects the result into documents you are building with UniPDF. It is a plugin rather than a standalone library: a small Go client that talks to a UniHTML server, which drives headless Chrome to do the rendering.
That means the CSS, the JavaScript, the web fonts and the flexbox all behave the way they do in a browser, because a browser is what draws them. A layout that looks right in Chrome converts to a PDF that looks the same.
Three parts
| Part | What it is | Where it runs |
|---|---|---|
github.com/unidoc/unihtml | The Go client. Builds a request, gets PDF pages back. | In your process |
| UniHTML server | HTTP service that stores the input and orchestrates the render. | A container you run |
| Headless Chrome | The renderer. | Inside the same container |
The client is the only part you write code against. It sends the HTML, or a URL, plus the page settings, and receives a PDF it hands to you as UniPDF pages.
The server ships as the unidoccloud/unihtml Docker image with Chrome already inside,
so running it is one docker run. It has no database and keeps nothing: uploads expire
after three minutes.
Where your HTML goes
UniHTML is the one UniDoc library that does not do all its work in your process. The markup, or the URL, is sent over HTTP to the server, which is the point of the design, and it means the usual “nothing leaves your machine” answer needs qualifying.
You run the server. It is a container in your own infrastructure, on your own network, under your own firewall rules, so the content goes to a service you control rather than to UniDoc or any third party. There is no hosted conversion endpoint and nothing is sent anywhere else.
So the server has to be reachable from your application, which is a deployment concern rather than a code one. And when a page pulls in a stylesheet, a font or a script from the public internet, the container is what fetches it, so it needs outbound access for those to load.
The license check is separate and behaves as it does elsewhere in UniDoc. A metered key reports usage counts and machine identifiers to the license server and never document content; an offline license makes no outbound call at all.
Does UniHTML send my HTML anywhere? covers this in the detail a security review will ask for.
What you can do with it
| Area | Covers |
|---|---|
| Input sources | An inline string, an HTML file, a directory of HTML with its assets, or a live URL. |
| Page setup | ISO page sizes, custom dimensions, orientation, margins, and waiting for scripts to finish. |
| PDF output | Write the PDF directly, take the rendered pages, or draw the HTML inline in a UniPDF document. |
| Chapters | Converted HTML as a numbered section of a larger report, with an outline bookmark. |
| Links | Anchors that stay clickable in the output. |
Because the output arrives as UniPDF pages, everything UniPDF does is available afterwards: signing, encryption, merging, watermarks, form fields.
What UniHTML does not do
Worth knowing before you commit to it.
It does not run without a server. There is no in-process fallback and no pure-Go
HTML renderer behind it. Connect health-checks the server and returns an error if it
cannot reach one, so a deployment plan for the container is part of adopting UniHTML.
The conversion also runs one way. UniHTML does not read PDFs or recover HTML from them.
It needs two licenses loaded, one per part. The client reads a UniPDF license from your process, and the server reads its own from its environment. One key satisfies both, but it has to be given to both. See how to license the UniHTML server.
The UniPDF import has to match UniHTML’s major, which is unipdf/v5. Releases before the
v5 move used v4, and the two cannot be mixed in one program.
Pages behind a login are out of reach. Nothing attaches a cookie or an Authorization
header to the navigation, so a URL that needs authentication comes back as the login
page. Fetch it in your own code and pass the markup in as a string instead.
Tagged PDF output is not supported. unihtml.Document satisfies the structure
methods on creator.Drawable with empty implementations, so converted HTML carries no
structure tree and cannot contribute to a PDF/UA document.
Ready to get started?
The getting started guide covers getting an API key, running the server, and writing your first conversion. The FAQ answers the questions that come up most, the server and licensing included.