summaryrefslogtreecommitdiff
path: root/pdf.go
diff options
context:
space:
mode:
authorNick White <git@njw.name>2021-08-09 16:34:01 +0100
committerNick White <git@njw.name>2021-08-09 16:34:01 +0100
commit2bac685f600b97676de14bb850e5b087f0d54b83 (patch)
treecd5be4708d35be87e4afe6471f1c2ccdd9d7f365 /pdf.go
parent69eeb41a33f6a764fc6baf1a95e629a6482b67ea (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.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/pdf.go b/pdf.go
index a0c6a63..be7f8a9 100644
--- a/pdf.go
+++ b/pdf.go
@@ -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()