aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmulator0002020-09-26 21:56:20 +0200
committerEmulator0002020-09-26 21:56:20 +0200
commit96f39fea9921292d5aa67f478bd3d8e947f127be (patch)
tree99593e8121655c125d326ceb105701c5226c6885
parent9c7a675498ed4d83a924e963cf9a610116e6db7e (diff)
downloadpdf_form-96f39fea9921292d5aa67f478bd3d8e947f127be.tar.bz2
Bugfix in textfield Y position calculation
-rw-r--r--src/lib.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 7c215ee..e6200c1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -554,7 +554,14 @@ impl Form {
// Calcolate the text offset
let x = 2.0; // Suppose this fixed offset as we should have known the border here
- let y = 0.5 * (rect[3] - rect[1]) - 0.4 * font_size as f32; // Formula picked up from Poppler
+
+ // Formula picked up from Poppler
+ let dy = rect[1] - rect[3];
+ let y = if dy > 0.0 {
+ 0.5 * dy - 0.4 * font_size as f32
+ } else {
+ 0.5 * font_size as f32
+ };
// Set the text bounds, first are fixed at "1 0 0 1" and then the calculated x,y
content.operations.append(&mut vec![Operation::new(