From 04e0bd700c8e33c22e277c2c4898eaf9962f461f Mon Sep 17 00:00:00 2001 From: Jelmer Snoeck Date: Fri, 25 Sep 2015 13:46:33 +0100 Subject: Fpdf: add WriteAligned. WriteAligned allows a user to write a single string and align it. Previously, Write() would only write with Left alignment. Sometimes, you want to align a specific text string to the center or the right. HTMLBasic: add
tag. This allows a user to center text within the HTML block. This way they do not have to split up their input. A new line will be created automatically before and after the centered text. --- fpdf_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'fpdf_test.go') diff --git a/fpdf_test.go b/fpdf_test.go index ff8c5da..966767f 100644 --- a/fpdf_test.go +++ b/fpdf_test.go @@ -463,6 +463,7 @@ func ExampleFpdf_HTMLBasicNew() { _, lineHt = pdf.GetFontSize() htmlStr := `You can now easily print text mixing different styles: bold, ` + `italic, underlined, or all at once!

` + + `
You can also center text.
` + `You can also insert links on text, such as ` + `www.fpdf.org, or on an image: click on the logo.` html := pdf.HTMLBasicNew() @@ -488,6 +489,25 @@ func ExampleFpdf_AddFont() { // Successfully generated pdf/Fpdf_AddFont.pdf } +// This example demonstrates how to align text with the Write function. +func ExampleFpdf_WriteAligned() { + pdf := gofpdf.New("P", "mm", "A4", example.FontDir()) + pdf.AddPage() + pdf.SetFont("Helvetica", "", 12) + pdf.WriteAligned(0, 35, "This text is the default alignment, Left", "") + pdf.Ln(35) + pdf.WriteAligned(0, 35, "This text is aligned Left", "L") + pdf.Ln(35) + pdf.WriteAligned(0, 35, "This text is aligned Center", "C") + pdf.Ln(35) + pdf.WriteAligned(0, 35, "This text is aligned Right", "R") + fileStr := example.Filename("Fpdf_WriteAligned") + err := pdf.OutputFileAndClose(fileStr) + example.Summary(err, fileStr) + // Output: + // Successfully generated pdf/Fpdf_WriteAligned.pdf +} + // This example demonstrates how images are included in documents. func ExampleFpdf_Image() { pdf := gofpdf.New("P", "mm", "A4", "") -- cgit v1.2.1-24-ge1ad