func ExampleFpdf_SetAcceptPageBreakFunc() {
	var y0 float64
	var crrntCol int
	loremStr := lorem()
	pdf := gofpdf.New("L", "mm", "A4", "")
	const (
		pageWd = 297.0 // A4 210.0 x 297.0
		margin = 10.0
		gutter = 4
		colNum = 3
		colWd  = (pageWd - 2*margin - (colNum-1)*gutter) / colNum
	)
	setCol := func(col int) {
		crrntCol = col
		x := margin + float64(col)*(colWd+gutter)
		pdf.SetLeftMargin(x)
		pdf.SetX(x)
	}
	pdf.SetHeaderFunc(func() {
		titleStr := "gofpdf"
		pdf.SetFont("Helvetica", "B", 48)
		wd := pdf.GetStringWidth(titleStr) + 6
		pdf.SetX((pageWd - wd) / 2)
		pdf.SetTextColor(128, 128, 160)
		pdf.Write(12, titleStr[:2])
		pdf.SetTextColor(128, 128, 128)
		pdf.Write(12, titleStr[2:])
		pdf.Ln(20)
		y0 = pdf.GetY()
	})
	pdf.SetAcceptPageBreakFunc(func() bool {
		if crrntCol < colNum-1 {
			setCol(crrntCol + 1)
			pdf.SetY(y0)
			// Start new column, not new page
			return false
		}
		setCol(0)
		return true
	})
	pdf.AddPage()
	pdf.SetFont("Times", "", 12)
	for j := 0; j < 20; j++ {
		if j == 1 {
			pdf.Image(example.ImageFile("fpdf.png"), -1, 0, colWd, 0, true, "", 0, "")
		} else if j == 5 {
			pdf.Image(example.ImageFile("golang-gopher.png"),
				-1, 0, colWd, 0, true, "", 0, "")
		}
		pdf.MultiCell(colWd, 5, loremStr, "", "", false)
		pdf.Ln(-1)
	}
	fileStr := example.Filename("Fpdf_SetAcceptPageBreakFunc_landscape")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
	// Output:
	// Successfully generated pdf/Fpdf_SetAcceptPageBreakFunc_landscape.pdf
}
// This example demonstrates Landscape mode with images.
This example demonstrates Landscape mode with images.
// This example demonstrates Landscape mode with images .
func ExampleFpdf_SetAcceptPageBreakFunc() {
	var y0 float64
	var crrntCol int
	loremStr := lorem()
	pdf := gofpdf.New("L", "mm", "A4", "")
	const (
		pageWd = 297.0 
		margin = 10.0
		gutter = 4
		colNum = 3
		colWd  = (pageWd - 2*margin - (colNum-1)*gutter) / colNum
	)
	setCol := func(col int) {
		crrntCol = col
		x := margin + float64(col)*(colWd+gutter)
		pdf.SetLeftMargin(x)
		pdf.SetX(x)
	}
	pdf.SetHeaderFunc(func() {
		titleStr := "gofpdf"
		pdf.SetFont("Helvetica", "B", 48)
		wd := pdf.GetStringWidth(titleStr) + 6
		pdf.SetX((pageWd - wd) / 2)
		pdf.SetTextColor(128, 128, 160)
		pdf.Write(12, titleStr[:2])
		pdf.SetTextColor(128, 128, 128)
		pdf.Write(12, titleStr[2:])
		pdf.Ln(20)
		y0 = pdf.GetY()
	})
	pdf.SetAcceptPageBreakFunc(func() bool {
		if crrntCol < colNum-1 {
			setCol(crrntCol + 1)
			pdf.SetY(y0)
			return false
		}
		setCol(0)
		return true
	})
	pdf.AddPage()
	pdf.SetFont("Times", "", 12)
	for j := 0; j < 20; j++ {
		if j == 1 {
			pdf.Image(example.ImageFile("fpdf.png"), -1, 0, colWd, 0, true, "", 0, "")
		} else if j == 5 {
			pdf.Image(example.ImageFile("golang-gopher.png"),
				-1, 0, colWd, 0, true, "", 0, "")
		}
		pdf.MultiCell(colWd, 5, loremStr, "", "", false)
		pdf.Ln(-1)
	}
	fileStr := example.Filename("Fpdf_SetAcceptPageBreakFunc_landscape")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
}
func ExampleFpdf_SetAcceptPageBreakFunc ( ) { var y0 float64 var crrntCol int loremStr := lorem ( ) pdf := gofpdf . New ( " " , " " , " " , " " ) const ( pageWd = 297.0 margin = 10.0 gutter = 4 colNum = 3 colWd = ( pageWd - 2 * margin - ( colNum - 1 ) * gutter ) / colNum ) setCol := func ( col int ) { crrntCol = col x := margin + float64 ( col ) * ( colWd + gutter ) pdf . SetLeftMargin ( x ) pdf . SetX ( x ) } pdf . SetHeaderFunc ( func ( ) { titleStr := " " pdf . SetFont ( " " , " " , 48 ) wd := pdf . GetStringWidth ( titleStr ) + 6 pdf . SetX ( ( pageWd - wd ) / 2 ) pdf . SetTextColor ( 128 , 128 , 160 ) pdf . Write ( 12 , titleStr [ : 2 ] ) pdf . SetTextColor ( 128 , 128 , 128 ) pdf . Write ( 12 , titleStr [ 2 : ] ) pdf . Ln ( 20 ) y0 = pdf . GetY ( ) } ) pdf . SetAcceptPageBreakFunc ( func ( ) bool { if crrntCol < colNum - 1 { setCol ( crrntCol + 1 ) pdf . SetY ( y0 ) return false } setCol ( 0 ) return true } ) pdf . AddPage ( ) pdf . SetFont ( " " , " " , 12 ) for j := 0 ; j < 20 ; j ++ { if j == 1 { pdf . Image ( example . ImageFile ( " " ) , - 1 , 0 , colWd , 0 , true , " " , 0 , " " ) } else if j == 5 { pdf . Image ( example . ImageFile ( " " ) , - 1 , 0 , colWd , 0 , true , " " , 0 , " " ) } pdf . MultiCell ( colWd , 5 , loremStr , " " , " " , false ) pdf . Ln ( - 1 ) } fileStr := example . Filename ( " " ) err := pdf . OutputFileAndClose ( fileStr ) example . Summary ( err , fileStr ) }
This example demonstrates Landscape mode with images.
This example demonstrates Landscape mode with images .
// A4 210.0 x 297.0 // Start new column, not new page // Output: // Successfully generated pdf/Fpdf_SetAcceptPageBreakFunc_landscape.pdf