summaryrefslogtreecommitdiff
path: root/fpdf_test.go
diff options
context:
space:
mode:
authorKurt Jung <kurt.w.jung@gmail.com>2015-08-19 09:42:15 -0400
committerKurt Jung <kurt.w.jung@gmail.com>2015-08-19 09:42:15 -0400
commit27b605858db6d8f5439e9b689f70626801324f02 (patch)
treeb9ed9cb126f0ba8cbd26dc7282a30a9aa0c1a389 /fpdf_test.go
parentc2852e54f9dab4886e4679e7bb48513510444f02 (diff)
Add image information retrieval method and test
Diffstat (limited to 'fpdf_test.go')
-rw-r--r--fpdf_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/fpdf_test.go b/fpdf_test.go
index 81ff68f..b556713 100644
--- a/fpdf_test.go
+++ b/fpdf_test.go
@@ -1083,9 +1083,27 @@ func ExampleFpdf_RegisterImage() {
pdf.Image(imageFileStr, lf, tp, imgWd, imgHt, false, "", 0, "")
}
fileStr := exampleFilename("Fpdf_RegisterImage")
+ // Test the image information retrieval method
+ infoShow := func(imageStr string) {
+ imageStr = imageFile(imageStr)
+ info, ok := pdf.GetImageInfo(imageStr)
+ if ok {
+ if info.Width() > 0.0 {
+ fmt.Printf("Image %s is registered\n", imageStr)
+ } else {
+ fmt.Printf("Incorrect information for image %s\n", imageStr)
+ }
+ } else {
+ fmt.Printf("Image %s is not registered\n", imageStr)
+ }
+ }
+ infoShow(fileList[0])
+ infoShow("foo.png")
err := pdf.OutputFileAndClose(fileStr)
summary(err, fileStr)
// Output:
+ // Image image/logo-gray.png is registered
+ // Image image/foo.png is not registered
// Successfully generated pdf/Fpdf_RegisterImage.pdf
}