本文整理汇总了Golang中github.com/signintech/gopdf.GoPdf.Br方法的典型用法代码示例。如果您正苦于以下问题:Golang GoPdf.Br方法的具体用法?Golang GoPdf.Br怎么用?Golang GoPdf.Br使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/signintech/gopdf.GoPdf
的用法示例。
在下文中一共展示了GoPdf.Br方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{
PageSize: gopdf.Rect{W: 595.28, H: 841.89}, //595.28, 841.89 = A4
Protection: gopdf.PDFProtectionConfig{UseProtection: true,
Permissions: gopdf.PermissionsPrint | gopdf.PermissionsCopy | gopdf.PermissionsModify,
OwnerPass: []byte("1234"),
UserPass: []byte("5555")},
})
pdf.AddPage()
err := pdf.AddTTFFont("TakaoPGothic", "../ttf/TakaoPGothic.ttf")
if err != nil {
log.Print(err.Error())
return
}
pdf.SetLineWidth(2)
pdf.SetLineType("dashed")
pdf.SetLineType("dotted")
pdf.Line(10, 30, 585, 30)
err = pdf.SetFont("TakaoPGothic", "", 14)
if err != nil {
log.Print(err.Error())
return
}
//#1 pic
pdf.Image("../imgs/gopher.jpg", 200, 50, nil)
pdf.Cell(nil, "こんにちは")
pdf.Br(20)
pdf.WritePdf("protect.pdf")
}
示例2: main
//gopdf had no mechanism for set italic ( pdf.SetFont("SOMEFONT", "I", 14) ), but you can do like this.
func main() {
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{Unit: "pt", PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
pdf.AddPage()
err := pdf.AddTTFFont("DejaVuSerif", "../ttf/DejaVuSerif.ttf")
if err != nil {
log.Print(err.Error())
return
}
err = pdf.AddTTFFont("DejaVuSerif-Italic", "../ttf/DejaVuSerif-Italic.ttf")
if err != nil {
log.Print(err.Error())
return
}
err = pdf.SetFont("DejaVuSerif", "", 14)
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "Hi! This is nomal.")
pdf.Br(20)
err = pdf.SetFont("DejaVuSerif-Italic", "", 14)
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "Hi! This is italic.")
pdf.WritePdf("italic.pdf")
}
示例3: main
/*
Thank https://github.com/miiton for setLineType
*/
func main() {
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{Unit: "pt", PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
pdf.AddPage()
err := pdf.AddTTFFont("TakaoPGothic", "../ttf/TakaoPGothic.ttf")
if err != nil {
log.Print(err.Error())
return
}
pdf.SetLineWidth(2)
pdf.SetLineType("dashed")
//pdf.SetLineType("dotted")
pdf.Line(10, 30, 585, 30)
err = pdf.SetFont("TakaoPGothic", "", 14)
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "こんにちは")
pdf.Br(20)
pdf.WritePdf("line.pdf")
}
示例4: main
func main() {
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
pdf.AddPage()
err := pdf.AddTTFFont("Roboto", "../ttf/Roboto-Regular.ttf")
if err != nil {
log.Print(err.Error())
return
}
fontSize := 24
err = pdf.SetFont("Roboto", "", fontSize)
if err != nil {
log.Print(err.Error())
return
}
//pdf.SetGrayFill(0.5)
//pdf.Cell(nil, "Áa")
//Measure Width
text := "How can I cordinate the text that I want draw?"
pdf.Cell(nil, text)
realWidth, _ := pdf.MeasureTextWidth(text)
fmt.Printf("realWidth = %f", realWidth)
var parser core.TTFParser
err = parser.Parse("../ttf/Roboto-Regular.ttf")
if err != nil {
log.Print(err.Error())
return
}
//Measure Height
//get CapHeight (https://en.wikipedia.org/wiki/Cap_height)
cap := float64(float64(parser.CapHeight()) * 1000.00 / float64(parser.UnitsPerEm()))
//convert
realHeight := cap * (float64(fontSize) / 1000.0)
fmt.Printf("realHeight = %f", realHeight)
//test
pdf.Br(realHeight)
pdf.Cell(nil, "How can I cordinate the text that I want draw?")
pdf.Br(realHeight)
pdf.Cell(nil, "How can I cordinate the text that I want draw?123")
pdf.Br(realHeight)
pdf.Cell(nil, "How can I cordinate the text that I want draw?456")
pdf.WritePdf("hello.pdf")
}
示例5: main
/*
Thank https://github.com/miiton for write text color supported.
*/
func main() {
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
pdf.AddPage()
err := pdf.AddTTFFont("HDZB_5", "../ttf/wts11.ttf")
if err != nil {
log.Print(err.Error())
return
}
err = pdf.SetFont("HDZB_5", "", 14)
if err != nil {
log.Print(err.Error())
return
}
//
pdf.SetGrayFill(0.5)
pdf.Cell(nil, "gray")
pdf.SetTextColor(255, 0, 0)
pdf.Br(20)
pdf.Cell(nil, "red")
pdf.SetTextColor(0, 0, 0)
pdf.Br(20)
pdf.Cell(nil, "gray")
pdf.SetGrayFill(0)
pdf.Br(20)
pdf.Cell(nil, "black")
pdf.SetTextColor(0, 0, 255)
pdf.Br(20)
pdf.Cell(nil, "blue")
pdf.WritePdf("color.pdf")
}
示例6: main
func main() {
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
pdf.AddPage()
var err error
err = pdf.AddTTFFont("HDZB_5", "../ttf/wts11.ttf")
if err != nil {
log.Print(err.Error())
return
}
err = pdf.AddTTFFont("TakaoPGothic", "../ttf/TakaoPGothic.ttf")
if err != nil {
log.Print(err.Error())
return
}
err = pdf.AddTTFFont("loma", "../ttf/Loma.ttf")
if err != nil {
log.Print(err.Error())
return
}
err = pdf.AddTTFFont("namum", "../ttf/NanumBarunGothic.ttf")
//china
err = pdf.SetFont("HDZB_5", "", 14)
if err != nil {
log.Printf(err.Error())
return
}
err = pdf.AddTTFFont("Roboto", "../ttf/Roboto-Regular.ttf")
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "Hello")
pdf.Br(20)
pdf.Cell(nil, "您好")
pdf.Br(20)
//japan
err = pdf.SetFont("TakaoPGothic", "", 14)
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "こんにちは")
pdf.Br(20)
//thai
err = pdf.SetFont("loma", "", 14)
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "สวัสดี")
pdf.Br(20)
//test composite glyph
err = pdf.SetFont("Roboto", "", 14)
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "ÁÉÍÓÖŐÚÜŰ")
pdf.Br(20)
pdf.Cell(nil, "ÁÉÍÓÖŐÚÜŰ")
pdf.Br(20)
//korean
err = pdf.SetFont("namum", "", 14)
if err != nil {
log.Print(err.Error())
return
}
pdf.Cell(nil, "안녕하세요")
pdf.Br(20)
pdf.WritePdf("hello2.pdf")
}
示例7: TestHello2
func TestHello2(t *testing.T) {
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{Unit: "pt", PageSize: gopdf.Rect{W: 595.28, H: 841.89}}) //595.28, 841.89 = A4
pdf.AddPage()
var err error
err = pdf.AddTTFFont("HDZB_5", "./ttf/wts11.ttf")
if err != nil {
t.Error(err)
return
}
err = pdf.AddTTFFont("TakaoPGothic", "./ttf/TakaoPGothic.ttf")
if err != nil {
t.Error(err)
return
}
err = pdf.AddTTFFont("loma", "./ttf/Loma.ttf")
if err != nil {
t.Error(err)
return
}
err = pdf.AddTTFFont("namum", "./ttf/NanumBarunGothic.ttf")
//china
err = pdf.SetFont("HDZB_5", "", 14)
if err != nil {
t.Error(err)
return
}
pdf.Cell(nil, "Hello")
pdf.Br(20)
pdf.Cell(nil, "您好")
pdf.Br(20)
//japan
err = pdf.SetFont("TakaoPGothic", "", 14)
if err != nil {
t.Error(err)
return
}
pdf.Cell(nil, "こんにちは")
pdf.Br(20)
//thai
err = pdf.SetFont("loma", "", 14)
if err != nil {
t.Error(err)
return
}
pdf.Cell(nil, "สวัสดี")
pdf.Br(20)
//korean
err = pdf.SetFont("namum", "", 14)
if err != nil {
t.Error(err)
return
}
pdf.Cell(nil, "안녕하세요")
data, err := pdf.GetBytesPdfReturnErr()
if err != nil {
t.Error(err)
return
}
if len(data) <= 0 {
t.Error(err)
return
}
}