func ExampleFpdf_SplitLines_tables() {
	const (
		colCount = 3
		colWd    = 60.0
		marginH  = 15.0
		lineHt   = 5.5
		cellGap  = 2.0
	)
	// var colStrList [colCount]string
	type cellType struct {
		str  string
		list [][]byte
		ht   float64
	}
	var (
		cellList [colCount]cellType
		cell     cellType
	)

	pdf := gofpdf.New("P", "mm", "A4", "") // 210 x 297
	header := [colCount]string{"Column A", "Column B", "Column C"}
	alignList := [colCount]string{"L", "C", "R"}
	strList := loremList()
	pdf.SetMargins(marginH, 15, marginH)
	pdf.SetFont("Arial", "", 14)
	pdf.AddPage()

	// Headers
	pdf.SetTextColor(224, 224, 224)
	pdf.SetFillColor(64, 64, 64)
	for colJ := 0; colJ < colCount; colJ++ {
		pdf.CellFormat(colWd, 10, header[colJ], "1", 0, "CM", true, 0, "")
	}
	pdf.Ln(-1)
	pdf.SetTextColor(24, 24, 24)
	pdf.SetFillColor(255, 255, 255)

	// Rows
	y := pdf.GetY()
	count := 0
	for rowJ := 0; rowJ < 2; rowJ++ {
		maxHt := lineHt
		// Cell height calculation loop
		for colJ := 0; colJ < colCount; colJ++ {
			count++
			if count > len(strList) {
				count = 1
			}
			cell.str = strings.Join(strList[0:count], " ")
			cell.list = pdf.SplitLines([]byte(cell.str), colWd-cellGap-cellGap)
			cell.ht = float64(len(cell.list)) * lineHt
			if cell.ht > maxHt {
				maxHt = cell.ht
			}
			cellList[colJ] = cell
		}
		// Cell render loop
		x := marginH
		for colJ := 0; colJ < colCount; colJ++ {
			pdf.Rect(x, y, colWd, maxHt+cellGap+cellGap, "D")
			cell = cellList[colJ]
			cellY := y + cellGap + (maxHt-cell.ht)/2
			for splitJ := 0; splitJ < len(cell.list); splitJ++ {
				pdf.SetXY(x+cellGap, cellY)
				pdf.CellFormat(colWd-cellGap-cellGap, lineHt, string(cell.list[splitJ]), "", 0,
					alignList[colJ], false, 0, "")
				cellY += lineHt
			}
			x += colWd
		}
		y += maxHt + cellGap + cellGap
	}

	fileStr := example.Filename("Fpdf_SplitLines_tables")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
	// Output:
	// Successfully generated pdf/Fpdf_SplitLines_tables.pdf
}
// ExampleFpdf_SplitLines_tables demonstrates word-wrapped table cells
ExampleFpdf_SplitLines_tables demonstrates word-wrapped table cells
// ExampleFpdf_SplitLines_tables demonstrates word - wrapped table cells
func ExampleFpdf_SplitLines_tables() {
	const (
		colCount = 3
		colWd    = 60.0
		marginH  = 15.0
		lineHt   = 5.5
		cellGap  = 2.0
	)
	type cellType struct {
		str  string
		list [][]byte
		ht   float64
	}
	var (
		cellList [colCount]cellType
		cell     cellType
	)
	pdf := gofpdf.New("P", "mm", "A4", "") 
	header := [colCount]string{"Column A", "Column B", "Column C"}
	alignList := [colCount]string{"L", "C", "R"}
	strList := loremList()
	pdf.SetMargins(marginH, 15, marginH)
	pdf.SetFont("Arial", "", 14)
	pdf.AddPage()
	pdf.SetTextColor(224, 224, 224)
	pdf.SetFillColor(64, 64, 64)
	for colJ := 0; colJ < colCount; colJ++ {
		pdf.CellFormat(colWd, 10, header[colJ], "1", 0, "CM", true, 0, "")
	}
	pdf.Ln(-1)
	pdf.SetTextColor(24, 24, 24)
	pdf.SetFillColor(255, 255, 255)
	y := pdf.GetY()
	count := 0
	for rowJ := 0; rowJ < 2; rowJ++ {
		maxHt := lineHt
		for colJ := 0; colJ < colCount; colJ++ {
			count++
			if count > len(strList) {
				count = 1
			}
			cell.str = strings.Join(strList[0:count], " ")
			cell.list = pdf.SplitLines([]byte(cell.str), colWd-cellGap-cellGap)
			cell.ht = float64(len(cell.list)) * lineHt
			if cell.ht > maxHt {
				maxHt = cell.ht
			}
			cellList[colJ] = cell
		}
		x := marginH
		for colJ := 0; colJ < colCount; colJ++ {
			pdf.Rect(x, y, colWd, maxHt+cellGap+cellGap, "D")
			cell = cellList[colJ]
			cellY := y + cellGap + (maxHt-cell.ht)/2
			for splitJ := 0; splitJ < len(cell.list); splitJ++ {
				pdf.SetXY(x+cellGap, cellY)
				pdf.CellFormat(colWd-cellGap-cellGap, lineHt, string(cell.list[splitJ]), "", 0,
					alignList[colJ], false, 0, "")
				cellY += lineHt
			}
			x += colWd
		}
		y += maxHt + cellGap + cellGap
	}
	fileStr := example.Filename("Fpdf_SplitLines_tables")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
}
func ExampleFpdf_SplitLines_tables ( ) { const ( colCount = 3 colWd = 60.0 marginH = 15.0 lineHt = 5.5 cellGap = 2.0 ) type cellType struct { str string list [ ] [ ] byte ht float64 } var ( cellList [ colCount ] cellType cell cellType ) pdf := gofpdf . New ( " " , " " , " " , " " ) header := [ colCount ] string { " " , " " , " " } alignList := [ colCount ] string { " " , " " , " " } strList := loremList ( ) pdf . SetMargins ( marginH , 15 , marginH ) pdf . SetFont ( " " , " " , 14 ) pdf . AddPage ( ) pdf . SetTextColor ( 224 , 224 , 224 ) pdf . SetFillColor ( 64 , 64 , 64 ) for colJ := 0 ; colJ < colCount ; colJ ++ { pdf . CellFormat ( colWd , 10 , header [ colJ ] , " " , 0 , " " , true , 0 , " " ) } pdf . Ln ( - 1 ) pdf . SetTextColor ( 24 , 24 , 24 ) pdf . SetFillColor ( 255 , 255 , 255 ) y := pdf . GetY ( ) count := 0 for rowJ := 0 ; rowJ < 2 ; rowJ ++ { maxHt := lineHt for colJ := 0 ; colJ < colCount ; colJ ++ { count ++ if count > len ( strList ) { count = 1 } cell . str = strings . Join ( strList [ 0 : count ] , " " ) cell . list = pdf . SplitLines ( [ ] byte ( cell . str ) , colWd - cellGap - cellGap ) cell . ht = float64 ( len ( cell . list ) ) * lineHt if cell . ht > maxHt { maxHt = cell . ht } cellList [ colJ ] = cell } x := marginH for colJ := 0 ; colJ < colCount ; colJ ++ { pdf . Rect ( x , y , colWd , maxHt + cellGap + cellGap , " " ) cell = cellList [ colJ ] cellY := y + cellGap + ( maxHt - cell . ht ) / 2 for splitJ := 0 ; splitJ < len ( cell . list ) ; splitJ ++ { pdf . SetXY ( x + cellGap , cellY ) pdf . CellFormat ( colWd - cellGap - cellGap , lineHt , string ( cell . list [ splitJ ] ) , " " , 0 , alignList [ colJ ] , false , 0 , " " ) cellY += lineHt } x += colWd } y += maxHt + cellGap + cellGap } fileStr := example . Filename ( " " ) err := pdf . OutputFileAndClose ( fileStr ) example . Summary ( err , fileStr ) }
ExampleFpdf_SplitLines_tables demonstrates word-wrapped table cells
ExampleFpdf_SplitLines_tables demonstrates word - wrapped table cells
// var colStrList [colCount]string // 210 x 297 // Headers // Rows // Cell height calculation loop // Cell render loop // Output: // Successfully generated pdf/Fpdf_SplitLines_tables.pdf