From 8cbb57960dcb46f88dbb494a73ec226f0565cc7f Mon Sep 17 00:00:00 2001 From: Adrian-George Bostan Date: Mon, 22 Oct 2018 22:07:08 +0300 Subject: [PATCH] Add SetText method to the styled paragraph component --- pdf/creator/styled_paragraph.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pdf/creator/styled_paragraph.go b/pdf/creator/styled_paragraph.go index e79f37cd..68604732 100644 --- a/pdf/creator/styled_paragraph.go +++ b/pdf/creator/styled_paragraph.go @@ -119,6 +119,12 @@ func (p *StyledParagraph) Reset() { p.chunks = []*TextChunk{} } +// SetText replaces all the of the paragraph with the specified one. +func (p *StyledParagraph) SetText(text string) *TextChunk { + p.Reset() + return p.Append(text) +} + // SetTextAlignment sets the horizontal alignment of the text within the space provided. func (p *StyledParagraph) SetTextAlignment(align TextAlignment) { p.alignment = align