Using this code:
funcmain(){pdf:=fpdf.New(fpdf.OrientationPortrait,fpdf.UnitMillimeter,fpdf.PageSizeA4,"")pdf.SetFont("Arial","",13)contentPageTemplate:=pdf.CreateTemplate(func(tpl*fpdf.Tpl){tpl.SetHeaderFuncMode(func(){tpl.SetY(5)tpl.SetFont("Arial","B",15)tpl.Cell(80,0,"")tpl.CellFormat(30,10,"Title","1",0,"C",false,0,"")tpl.Ln(20)tpl.CellFormat(30,10,"Class Report","",0,fpdf.AlignCenter,false,0,"")},true)tpl.SetFooterFunc(func(){tpl.SetY(-15)tpl.SetFont("Arial","I",13)tpl.CellFormat(0,10,fmt.Sprintf("Page %d/{nb}",tpl.PageNo()),"",0,"C",false,0,"")})})pdf.AliasNbPages("")pdf.AddPage()pdf.CellFormat(0,10,"This is the front cover","",0,fpdf.AlignCenter,false,0,"")pdf.AddPage()pdf.UseTemplate(contentPageTemplate)pdf.CellFormat(0,10,"This is the a content page with header and footer","",0,fpdf.AlignCenter,false,0,"")log.Println(pdf.PageCount())pdf.OutputFileAndClose("test.pdf")}I am not able to add a header and footer on the second page. Is this the wrong way to do it?
Also, I am not sure if the authors of fpdf are open to using the Discussions page for this repo. I was looking for it to ask the question but it seems it is only possible for me to do so via opening an issue.
Thanks!
Using this code:
```golang
func main() {
pdf := fpdf.New(fpdf.OrientationPortrait, fpdf.UnitMillimeter, fpdf.PageSizeA4, "")
pdf.SetFont("Arial", "", 13)
contentPageTemplate := pdf.CreateTemplate(func(tpl *fpdf.Tpl) {
tpl.SetHeaderFuncMode(func() {
tpl.SetY(5)
tpl.SetFont("Arial", "B", 15)
tpl.Cell(80, 0, "")
tpl.CellFormat(30, 10, "Title", "1", 0, "C", false, 0, "")
tpl.Ln(20)
tpl.CellFormat(30, 10, "Class Report", "", 0, fpdf.AlignCenter, false, 0, "")
}, true)
tpl.SetFooterFunc(func() {
tpl.SetY(-15)
tpl.SetFont("Arial", "I", 13)
tpl.CellFormat(0, 10, fmt.Sprintf("Page %d/{nb}", tpl.PageNo()),
"", 0, "C", false, 0, "")
})
})
pdf.AliasNbPages("")
pdf.AddPage()
pdf.CellFormat(0, 10, "This is the front cover", "", 0, fpdf.AlignCenter, false, 0, "")
pdf.AddPage()
pdf.UseTemplate(contentPageTemplate)
pdf.CellFormat(0, 10, "This is the a content page with header and footer", "", 0, fpdf.AlignCenter, false, 0, "")
log.Println(pdf.PageCount())
pdf.OutputFileAndClose("test.pdf")
}
```
I am not able to add a header and footer on the second page. Is this the wrong way to do it?
Also, I am not sure if the authors of fpdf are open to using the Discussions page for this repo. I was looking for it to ask the question but it seems it is only possible for me to do so via opening an issue.
Thanks!