Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Commit

Permalink
Add example usage for SetWordSpacing
Browse files Browse the repository at this point in the history
  • Loading branch information
wmatusiak committed Feb 21, 2019
1 parent 6b86862 commit 10d79b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fpdf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified pdf/reference/Fpdf_WriteAligned.pdf
Binary file not shown.

0 comments on commit 10d79b6

Please sign in to comment.