Does UniOffice Supports Docx to PDF conversion?
Yes, UniOffice supports *.docx to PDF conversion. There are many supported options for documents conversion to PDF. Docx to PDF converter supports almost all of the main formatting in MS Word files that are not limited to header/footer, charts, tables, text-only documents in the landscape and portrait, and many other options.
Source Code:
/* * This example showcases PDF generation from docx document with UniOffice package. */ package main import ( "fmt" "log" "os" "github.com/unidoc/unipdf/v4/common/license" "github.com/unidoc/unioffice/v2/common/license" "github.com/unidoc/unioffice/v2/document" "github.com/unidoc/unioffice/v2/document/convert" ) func init() { // Make sure to load your metered License API key prior to using the library. // If you need a key, you can sign up and create a free one at https://cloud.unidoc.io err := unipdflicense.SetMeteredKey(os.Getenv(`UNIDOC_LICENSE_API_KEY`)) if err != nil { fmt.Printf("ERROR: Failed to set metered key: %v\n", err) fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\n") fmt.Printf("If you don't have one - Grab one in the Free Tier at https://cloud.unidoc.io\n") panic(err) } // This example requires both for unioffice and unipdf. err = license.SetMeteredKey(os.Getenv(`UNIDOC_LICENSE_API_KEY`)) if err != nil { fmt.Printf("ERROR: Failed to set metered key: %v\n", err) fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\n") fmt.Printf("If you don't have one - Grab one in the Free Tier at https://cloud.unidoc.io\n") panic(err) } } var filenames = []string{ "chart", "headers_footers", "image_square", "table", "text_only_portrait", "text_only_landscape", "textbox_anchor", "textbox_inline", } func main() { for _, filename := range filenames { outputPath := fmt.Sprintf("output/%s.pdf", filename) doc, err := document.Open(filename + ".docx") if err != nil { log.Fatalf("error opening document: %s", err) } defer doc.Close() c := convert.ConvertToPdf(doc) err = c.WriteToFile(outputPath) if err != nil { log.Fatalf("error converting document: %s", err) } } }
The above mention example will allow you to convert the different files into PDF. The files used in the examples are chart, headers_footers, image_squre, table, text_only_portrait, text_only_landscape, textbox_anchor, textox_inline. These files' names show the content in the file. This example will convert the chart file into chart.pdf and other files to their respective names in PDF.