---------------------------------------------------------------- 另外,还有一个库已经证实是已经被收购了的。 "github.com/unidoc/unioffice/document" //不行,会提示 Unlicensed version of UniOffice //似乎是收购的 "baliance.com/gooxml/document"
The Portable Document Format (PDF) is a file format used to present documents in a manner independent of application software, hardware, and operating systems.[3] Each PDF file encapsulates a complete description of a fixed-layout flat document, including the text, fonts, graphics, and other information needed to display it.
func main() { pdf := gofpdf.New("P", "mm", "A4", "") pdf.AddPage() pdf.SetFont("Helvetica", "", 20) _, lineHt := pdf.GetFontSize() pdf.Write(lineHt, "To find out what's new in this tutorial, click ") pdf.SetFont("", "U", 0) link := pdf.AddLink() pdf.WriteLinkID(lineHt, "here", link) pdf.SetFont("", "", 0) // Second page: image link and basic HTML with link pdf.AddPage() pdf.SetLink(link, 0, -1) pdf.Image("test.png", 10, 12, 30, 0, false, "", 0, "http://blog.csdn.net/wangshubo1989?viewmode=contents") pdf.SetLeftMargin(45) pdf.SetFontSize(14) _, lineHt = pdf.GetFontSize() htmlStr := `You can now easily print text mixing different styles: bold, ` + `italic, underlined, or all at once!
` + `
You can also center text.
` + `Or align it to the right.` + `You can also insert links on text, such as ` + `http://blog.csdn.net/wangshubo1989?viewmode=contents, or on an image: click on the logo.` html := pdf.HTMLBasicNew() html.Write(lineHt, htmlStr) err := pdf.OutputFileAndClose("write_html.pdf") if err != nil { fmt.Println(err) } }