From 9ac309464a0e80bef81b9275f41af6dec9ebc114 Mon Sep 17 00:00:00 2001 From: Adrian-George Bostan Date: Fri, 30 Nov 2018 18:21:47 +0200 Subject: [PATCH] Adjust annotation position for all paragraph alignments --- pdf/creator/styled_paragraph.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pdf/creator/styled_paragraph.go b/pdf/creator/styled_paragraph.go index 4bcae471..bceab4c4 100644 --- a/pdf/creator/styled_paragraph.go +++ b/pdf/creator/styled_paragraph.go @@ -654,12 +654,18 @@ func drawStyledParagraphOnBlock(blk *Block, p *StyledParagraph, ctx DrawContext) } } else if p.alignment == TextAlignmentCenter { // Start with an offset of half of the remaining line space. - shift := (wrapWidth - width - spaceWidth) / 2 / defaultFontSize + offset := (wrapWidth - width - spaceWidth) / 2 + shift := offset / defaultFontSize objs = append(objs, core.MakeFloat(-shift)) + + currX += offset / 1000.0 } else if p.alignment == TextAlignmentRight { // Push the text at the end of the line. - shift := (wrapWidth - width - spaceWidth) / defaultFontSize + offset := (wrapWidth - width - spaceWidth) + shift := offset / defaultFontSize objs = append(objs, core.MakeFloat(-shift)) + + currX += offset / 1000.0 } if len(objs) > 0 {