summaryrefslogtreecommitdiff
path: root/fpdf.go
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2018-06-15 21:44:55 -0400
committerKurt <kurt.w.jung@gmail.com>2018-06-15 21:44:55 -0400
commita4b0fd17b669b43f74a6baa7e93b71d765b82d97 (patch)
tree3c442faefd7829220c26d17c7019f1fa8259bacd /fpdf.go
parent0298ebb7bb539ad17daadce86bedbdfd56c2bcd4 (diff)
Support negative X position when placing image
Diffstat (limited to 'fpdf.go')
-rw-r--r--fpdf.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/fpdf.go b/fpdf.go
index f6ec511..494f1b2 100644
--- a/fpdf.go
+++ b/fpdf.go
@@ -2421,7 +2421,7 @@ func (f *Fpdf) ImageTypeFromMime(mimeStr string) (tp string) {
return
}
-func (f *Fpdf) imageOut(info *ImageInfoType, x, y, w, h float64, flow bool, link int, linkStr string) {
+func (f *Fpdf) imageOut(info *ImageInfoType, x, y, w, h float64, allowNegativeX, flow bool, link int, linkStr string) {
// Automatic width and height calculation if needed
if w == 0 && h == 0 {
// Put image at 96 dpi
@@ -2464,8 +2464,10 @@ func (f *Fpdf) imageOut(info *ImageInfoType, x, y, w, h float64, flow bool, link
y = f.y
f.y += h
}
- if x < 0 {
- x = f.x
+ if !allowNegativeX {
+ if x < 0 {
+ x = f.x
+ }
}
// dbg("h %.2f", h)
// q 85.04 0 0 NaN 28.35 NaN cm /I2 Do Q
@@ -2531,7 +2533,7 @@ func (f *Fpdf) ImageOptions(imageNameStr string, x, y, w, h float64, flow bool,
if f.err != nil {
return
}
- f.imageOut(info, x, y, w, h, flow, link, linkStr)
+ f.imageOut(info, x, y, w, h, options.AllowNegativePosition, flow, link, linkStr)
return
}
@@ -2559,9 +2561,13 @@ func (f *Fpdf) RegisterImageReader(imgName, tp string, r io.Reader) (info *Image
// to true (understanding that not all images will have this info
// available). However, for backwards compatibility with previous
// versions of the API, it defaults to false.
+//
+// AllowNegativePosition can be set to true in order to prevent the default
+// coercion of negative x values to the current x position.
type ImageOptions struct {
- ImageType string
- ReadDpi bool
+ ImageType string
+ ReadDpi bool
+ AllowNegativePosition bool
}
// RegisterImageOptionsReader registers an image, reading it from Reader r, adding it