Skip to content

Commit

Permalink
Fix empty content bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hjr265 committed Sep 14, 2023
1 parent c124547 commit 1c5ab44
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,23 @@ func (b PDFBuilder) Build(name string, pr Print) error {
if headerextra != "" {
header += " · " + headerextra
}
headerlines, err := pdf.SplitText(header, pagesize.W-pdf.MarginLeft()-pdf.MarginRight())
if err != nil {
return err
var headerlines []string
if header != "" {
headerlines, err = pdf.SplitText(header, pagesize.W-pdf.MarginLeft()-pdf.MarginRight())
if err != nil {
return err
}
}

linesperpage -= len(headerlines) + 2

lines, err := pdf.SplitText(b.tabToSpaces(pr.Content), pagesize.W-pdf.MarginLeft()-pdf.MarginRight())
if err != nil {
return err
content := b.tabToSpaces(pr.Content)
var lines []string
if content != "" {
lines, err = pdf.SplitText(content, pagesize.W-pdf.MarginLeft()-pdf.MarginRight())
if err != nil {
return err
}
}

if b.cfg.Printd.ReduceBlankLines {
Expand Down

0 comments on commit 1c5ab44

Please sign in to comment.