Skip to content

Commit

Permalink
feat(generate): underlay every second line in text output
Browse files Browse the repository at this point in the history
Signed-off-by: Universal Studio <[email protected]>
  • Loading branch information
TMUniversal committed Apr 2, 2024
1 parent befba1b commit db33b4e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/makeFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,23 @@ func (p *PaperCrypt) GetPDF(noQR bool, lowerCaseEncoding bool) ([]byte, error) {

// print data lines
dataLines := strings.Split(parts[1], "\n")
pdf.SetFont(PdfMonoFont, "B", 10)

// cut empty lines (should be one at the end)
filtered := dataLines[:0]
for _, line := range dataLines {
if line != "" {
filtered = append(filtered, line)
}
}

pdf.SetFont(PdfMonoFont, "B", 10)
for n, line := range filtered {
// mark every second line with a grey background
if n%2 == 0 {
pdf.SetFillColor(240, 240, 240)
pdf.Rect(20, pdf.GetY(), 166, 5, "F")
}

pdf.Cell(0, 5, line)
pdf.Ln(5)
}
Expand Down

0 comments on commit db33b4e

Please sign in to comment.