Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion fpdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,58 @@ func (f *Fpdf) CellFormat(w, h float64, txtStr, borderStr string, ln int,
f.ws = 0
f.out("0 Tw")
}
f.AddPageFormat(f.curOrientation, f.curPageSize)
if f.PageNo() == f.PageCount() {
f.AddPageFormat(f.curOrientation, f.curPageSize)
} else {
familyStr := f.fontFamily
style := f.fontStyle
if f.underline {
style += "U"
}
if f.strikeout {
style += "S"
}
fontsize := f.fontSizePt
lw := f.lineWidth
dc := f.color.draw
fc := f.color.fill
tc := f.color.text
cf := f.colorFlag

f.page += 1
f.y = f.tMargin

// Set line cap style to current value
// f.out("2 J")
f.outf("%d J", f.capStyle)
// Set line join style to current value
f.outf("%d j", f.joinStyle)
// Set line width
f.lineWidth = lw
f.outf("%.2f w", lw*f.k)
// Set dash pattern
if len(f.dashArray) > 0 {
f.outputDashPattern()
}
// Set font
if familyStr != "" {
f.SetFont(familyStr, style, fontsize)
if f.err != nil {
return
}
}
// Set colors
f.color.draw = dc
if dc.str != "0 G" {
f.out(dc.str)
}
f.color.fill = fc
if fc.str != "0 g" {
f.out(fc.str)
}
f.color.text = tc
f.colorFlag = cf
Comment on lines +2572 to +2619
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be a copy-paste of some of the content of AddPageFormat, w/o the "page open" prolog and some cleanup "postlog".

perhaps we could refactor AddPageFormat to use a non-exported method that does essentially what you copy-pasted here, and use that new non-exported method there ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Wanted to keep the PR as short as possible but let's make it clean ;)

I'll be quite busy the next few days but I'll try to make the changes until end of week.

}
if f.err != nil {
return
}
Expand Down