diff options
author | Nick White <git@njw.name> | 2021-08-09 16:34:01 +0100 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-08-09 16:34:01 +0100 |
commit | 2bac685f600b97676de14bb850e5b087f0d54b83 (patch) | |
tree | cd5be4708d35be87e4afe6471f1c2ccdd9d7f365 /pdf.go | |
parent | 69eeb41a33f6a764fc6baf1a95e629a6482b67ea (diff) |
pdf: use same line height and origin for all words on a line as it makes things neater in the PDF in most cases
Diffstat (limited to 'pdf.go')
-rw-r--r-- | pdf.go | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -108,20 +108,20 @@ func (p *Fpdf) AddPage(imgpath, hocrpath string, smaller bool) error { p.fpdf.SetTextRenderingMode(3) for _, l := range h.Lines { - coords, err := hocr.BoxCoords(l.Title) + linecoords, err := hocr.BoxCoords(l.Title) if err != nil { continue } - lineheight := coords[3] - coords[1] + lineheight := linecoords[3] - linecoords[1] for _, w := range l.Words { - coords, err = hocr.BoxCoords(w.Title) + coords, err := hocr.BoxCoords(w.Title) if err != nil { continue } - p.fpdf.SetXY(pxToPt(coords[0]), pxToPt(coords[1])) + p.fpdf.SetXY(pxToPt(coords[0]), pxToPt(linecoords[1])) p.fpdf.SetCellMargin(0) p.fpdf.SetFontSize(pxToPt(lineheight)) - p.fpdf.CellFormat(pxToPt(coords[2] - coords[0]), pxToPt(coords[3] - coords[1]), html.UnescapeString(w.Text)+" ", "", 0, "T", false, 0, "") + p.fpdf.CellFormat(pxToPt(coords[2] - coords[0]), pxToPt(lineheight), html.UnescapeString(w.Text)+" ", "", 0, "T", false, 0, "") } } return p.fpdf.Error() |