summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 86fae86..d84de54 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -799,6 +799,13 @@ func ExampleFpdf_WriteAligned() {
pdf.WriteAligned(0, 35, "This text is aligned Center", "C")
pdf.Ln(35)
pdf.WriteAligned(0, 35, "This text is aligned Right", "R")
+ pdf.Ln(35)
+ line := "This text fill line using word spacing. This can by used to write justified text"
+ leftMargin, _, rightMargin, _ := pdf.GetMargins()
+ pageWidth, _ := pdf.GetPageSize()
+ pageWidth -= leftMargin + rightMargin
+ pdf.SetWordSpacing((pageWidth - pdf.GetStringWidth(line)) / float64(strings.Count(line, " ")))
+ pdf.WriteAligned(pageWidth, 35, line, "L")
fileStr := example.Filename("Fpdf_WriteAligned")
err := pdf.OutputFileAndClose(fileStr)
example.Summary(err, fileStr)