HTML
JPG
PDF
XML
DOCX
PDF
Convert HTML to PDF in Go SDK
Export HTML documents to multiple formats including PDF with Aspose.PDF Cloud Go SDK
Get StartedHow to Convert HTML to PDF Using Go SDK
To convert HTML to PDF, we’ll use Aspose.PDF Cloud Go SDK This Cloud Go SDK assists Go programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Go programming language via Aspose.PDF REST API. Use the following command from the Package Manager Console.
Package Manager Console Command
go get -u github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25
Steps to Convert HTML to PDF via Go
Aspose.PDF Cloud Go developers can easily load & convert HTML files to PDF in just a few lines of code.
- Uploading a HTML file to Aspose Cloud Storage.
- Converting the HTML to a PDF.
- Saving the output PDF in cloud storage.
This sample code shows HTML to PDF Cloud Go SDK Conversion
package main
import (
"fmt"
"path"
asposepdfcloud "github.com/aspose-pdf-cloud/aspose-pdf-cloud-go/v25"
)
func convertHtmlToPdf(pdf_api *asposepdfcloud.PdfApiService, html_document string, html_zip string, pdf_name string, remote_folder string) {
args := map[string]interface{}{
"folder": remote_folder,
"height": float64(842),
"width": float64(595),
"htmlFileName": html_document,
}
src_path := path.Join(remote_folder, html_document)
result, httpResponse, err := pdf_api.PutHtmlInStorageToPdf(pdf_name, src_path, args)
if err != nil {
fmt.Println(err.Error())
} else if httpResponse.StatusCode < 200 || httpResponse.StatusCode > 299 {
fmt.Println("Unexpected error!")
} else {
fmt.Println(result)
}
}
Other Supported Conversions
You can also convert many other file formats including few listed below.
BMP TO PDF (Bitmap Image)
CGM TO PDF (Microsoft Word Binary Format)
EMF TO PDF (Office 2007+ Words Document)
EPUB TO PDF (Enhanced Metafile Format)
GIF TO PDF (Graphical Interchange Format)
HTML TO PDF (Hyper Text Markup Language)
JPEG TO PDF (Joint Photographic Experts Group)
LATEX TO PDF (LaTeX Output Text)
PCL TO PDF (Printer Command Language)
MD TO PDF (Markdown)
PDF TO BMP (Bitmap Image)
PDF TO EPUB (E-book Format)
PDF TO GIF (Graphical Interchange Format)
PDF TO HTML (Hyper Text Markup Language)
PDF TO JPEG (Joint Photographic Experts Group)
PDF TO PDF/A (Portable Document Format)
PDF TO PNG (Portable Network Graphics)
PDF TO PPTX (Microsoft PowerPoint)
PDF TO SVG (Scalable Vector Graphics)
PDF TO TEX (Computer Graphics System)
PDF TO TIFF (Tagged Image Format)
PDF TO WORD (Microsoft Word Binary Format)
PDF TO XLSX (Microsoft Excel Open XML Format Spreadsheet file)
PDF TO XPS (XML Paper Specifications)
PNG TO PDF (Portable Network Graphics)
PS TO PDF (PostScript)
SVG TO PDF (Scalable Vector Graphics)
TEXT TO PDF (Text Document)
TIFF TO PDF (Tagged Image Format)
XPS TO PDF (XML Paper Specifications)