Skip to content
This repository has been archived by the owner on Nov 13, 2021. It is now read-only.

Alignment doesn't take alias expansion into account #214

Open
lassik opened this issue Dec 4, 2018 · 1 comment
Open

Alignment doesn't take alias expansion into account #214

lassik opened this issue Dec 4, 2018 · 1 comment

Comments

@lassik
Copy link

lassik commented Dec 4, 2018

Hi and thanks for the excellent library!

I found the following minor bug with the latest version: When you make a cell with right-aligned text, the width of the text is calculated before expanding aliases. If the alias is wider than its expansion (e.g. {nb} is wider than 1) then the text is not aligned all the way to the right. Instead, there's a gap between the text and the right border. The following program demonstrates it:

package main

import "github.com/jung-kurt/gofpdf"

func main() {
	pdf := gofpdf.New("P", "mm", "A4", "")
	pdf.SetFont("Helvetica", "", 16)
	pdf.AddPage()
	pdf.CellFormat(50, 10, "Without alias", "1", 0, "R", false, 0, "")
	pdf.CellFormat(50, 10, "With alias: {nb}", "1", 0, "R", false, 0, "")
	pdf.AliasNbPages("")
	pdf.OutputFileAndClose("test.pdf")
}
@jung-kurt
Copy link
Owner

Thanks for the report, @lassik. Aliasing is pretty lame with this library; the substitutions are strictly lexical with no awareness of the special formatting that put the '{nb}' key where it lands in the document. We could maybe implement some logic that puts the space difference between the key (for example, '{nb}') and the substitution value (for example, '42') some place. I will muse on this a bit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants