Multiple Page PDF Resume From HTML
This guide will demonstrate how to create a multipage resume from HTML using UniHTML.
Before you begin
You should get your API key from your UniCloud account.
If this is your first time using UniPDF SDK, follow this guide to set up a local development environment. To set up a UniHTML server follow this getting started guide.
Clone the project repository
In your terminal, clone the examples repository. It contains the Go code we will be using for this guide.
git clone [email protected]:unidoc/unihtml-examples.git
Navigate to the resume
folder in the unihtml-examples
directory.
cd unihtml-examples/resume
How it works
The necessary libraries are imported in the import
section, in lines 8-17
.
The metered License API key is loaded and set in the init
function defined in lines 19-26
.
The actual processing and generating PDF document is done in the main
function defined in lines 28-81
.
First the number of command line arguments is checked to make sure that the server URL is provided as a second argument. Then a connection is established to server identified by the provided URL using unihtml.Connect(os.Args[1])
. Line 44
creates unihtml.Document
object by loading the HTML file. Then the last page content is trimmed using TrimLastPageContent
method of unihtml.Document
. The document is drawn in line 51
using c.Draw(htmlDocument)
. An additional paragraph is created and added to bottom of the document in lines 57-63
. Finally, the document is written to a file in line 66
.
Run the code
Run the code using the following command to generate the PDF file. Replace the server address
with the actual address. E.g. localhost:8080
for a server running locally on port 8080
.
go run resume.go <server address>
Sample output