示例
文本
字间距、文本缩进和文本装饰示例
字间距
通过正值增大字符间距,或通过负值收紧字符间距。
doc := template.New(
template.WithPageSize(document.A4),
template.WithMargins(document.UniformEdges(document.Mm(20))),
)
page := doc.AddPage()
page.AutoRow(func(r *template.RowBuilder) {
r.Col(12, func(c *template.ColBuilder) {
c.Text("Letter Spacing Demo", template.FontSize(20), template.Bold())
c.Spacer(document.Mm(8))
c.Text("Normal spacing (0pt)")
c.Spacer(document.Mm(3))
c.Text("Letter spacing 1pt", template.LetterSpacing(1))
c.Spacer(document.Mm(3))
c.Text("Letter spacing 3pt", template.LetterSpacing(3))
c.Spacer(document.Mm(3))
c.Text("WIDE HEADER", template.FontSize(16), template.Bold(),
template.LetterSpacing(5))
c.Spacer(document.Mm(3))
c.Text("Tight spacing -0.5pt", template.LetterSpacing(-0.5))
})
})doc := template.New(
template.WithPageSize(document.A4),
template.WithMargins(document.UniformEdges(document.Mm(20))),
)
page := doc.AddPage()
page.AutoRow(func(r *template.RowBuilder) {
r.Col(12, func(c *template.ColBuilder) {
c.Text("Text Decoration Demo", template.FontSize(20), template.Bold())
c.Spacer(document.Mm(8))
c.Text("Normal text without decoration")
c.Spacer(document.Mm(4))
c.Text("Underlined text for emphasis", template.Underline())
c.Spacer(document.Mm(4))
c.Text("Strikethrough text for deletions", template.Strikethrough())
c.Spacer(document.Mm(4))
c.Text("Combined underline and strikethrough",
template.Underline(), template.Strikethrough())
c.Spacer(document.Mm(4))
c.Text("Colored underlined text",
template.Underline(),
template.TextColor(pdf.RGBHex(0x1565C0)),
template.FontSize(14))
c.Spacer(document.Mm(4))
c.Text("Bold underlined heading",
template.Bold(), template.Underline(), template.FontSize(16))
})
})