summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2019-07-20 12:24:24 -0400
committerKurt <kurt.w.jung@gmail.com>2019-07-20 12:24:24 -0400
commit4e47058871098a8e32dff39b461760b280bccff0 (patch)
tree23c50588e1b8bd40ef5f2e3979ac3910e781dcac
parent5a3837eac46daca22df96b6b65a184cafef7e03e (diff)
parentd17d13df9df41d4505501e831ff0ada5b2222ff8 (diff)
Merge branch 'estenssoros-ImageOptionsReader'
-rw-r--r--fpdf_test.go34
1 files changed, 32 insertions, 2 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 7ee0831..63c28c5 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -858,7 +858,37 @@ func ExampleFpdf_ImageOptions() {
// Successfully generated pdf/Fpdf_ImageOptions.pdf
}
-// This examples demonstrates Landscape mode with images.
+// ExampleFpdf_RegisterImageOptionsReader demonstrates how to load an image
+// from a io.Reader (in this case, a file) and register it with options.
+func ExampleFpdf_RegisterImageOptionsReader() {
+ var (
+ opt gofpdf.ImageOptions
+ pdfStr string
+ fl *os.File
+ err error
+ )
+
+ pdfStr = example.Filename("Fpdf_RegisterImageOptionsReader")
+ pdf := gofpdf.New("P", "mm", "A4", "")
+ pdf.AddPage()
+ pdf.SetFont("Arial", "", 11)
+ fl, err = os.Open(example.ImageFile("logo.png"))
+ if err == nil {
+ opt.ImageType = "png"
+ opt.AllowNegativePosition = true
+ _ = pdf.RegisterImageOptionsReader("logo", opt, fl)
+ fl.Close()
+ for x := -20.0; x <= 40.0; x += 5 {
+ pdf.ImageOptions("logo", x, x+30, 0, 0, false, opt, 0, "")
+ }
+ err = pdf.OutputFileAndClose(pdfStr)
+ }
+ example.Summary(err, pdfStr)
+ // Output:
+ // Successfully generated pdf/Fpdf_RegisterImageOptionsReader.pdf
+}
+
+// This example demonstrates Landscape mode with images.
func ExampleFpdf_SetAcceptPageBreakFunc() {
var y0 float64
var crrntCol int
@@ -918,7 +948,7 @@ func ExampleFpdf_SetAcceptPageBreakFunc() {
// Successfully generated pdf/Fpdf_SetAcceptPageBreakFunc_landscape.pdf
}
-// This examples tests corner cases as reported by the gocov tool.
+// This example tests corner cases as reported by the gocov tool.
func ExampleFpdf_SetKeywords() {
var err error
fileStr := example.Filename("Fpdf_SetKeywords")