func ExampleFpdf_Rect() {
	marginCell := 2. // margin of top/bottom of cell
	pdf := gofpdf.New("P", "mm", "A4", "")
	pdf.SetFont("Arial", "", 12)
	pdf.AddPage()
	pagew, pageh := pdf.GetPageSize()
	mleft, mright, _, mbottom := pdf.GetMargins()

	cols := []float64{60, 100, pagew - mleft - mright - 100 - 60}
	rows := [][]string{}
	for i := 1; i <= 30; i++ {
		word := fmt.Sprintf("%d:%s", i, strings.Repeat("A", i%100))
		rows = append(rows, []string{word, word, word})
	}

	for _, row := range rows {
		curx, y := pdf.GetXY()
		x := curx

		height := 0.
		_, lineHt := pdf.GetFontSize()

		for i, txt := range row {
			lines := pdf.SplitLines([]byte(txt), cols[i])
			h := float64(len(lines))*lineHt + marginCell*float64(len(lines))
			if h > height {
				height = h
			}
		}
		// add a new page if the height of the row doesn't fit on the page
		if pdf.GetY()+height > pageh-mbottom {
			pdf.AddPage()
			y = pdf.GetY()
		}
		for i, txt := range row {
			width := cols[i]
			pdf.Rect(x, y, width, height, "")
			pdf.MultiCell(width, lineHt+marginCell, txt, "", "", false)
			x += width
			pdf.SetXY(x, y)
		}
		pdf.SetXY(curx, y+height)
	}
	fileStr := example.Filename("Fpdf_WrappedTableCells")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
	// Output:
	// Successfully generated pdf/Fpdf_WrappedTableCells.pdf
}
// This example demonstrate wrapped table cells
This example demonstrate wrapped table cells
// This example demonstrate wrapped table cells
func ExampleFpdf_Rect() {
	marginCell := 2. 
	pdf := gofpdf.New("P", "mm", "A4", "")
	pdf.SetFont("Arial", "", 12)
	pdf.AddPage()
	pagew, pageh := pdf.GetPageSize()
	mleft, mright, _, mbottom := pdf.GetMargins()
	cols := []float64{60, 100, pagew - mleft - mright - 100 - 60}
	rows := [][]string{}
	for i := 1; i <= 30; i++ {
		word := fmt.Sprintf("%d:%s", i, strings.Repeat("A", i%100))
		rows = append(rows, []string{word, word, word})
	}
	for _, row := range rows {
		curx, y := pdf.GetXY()
		x := curx
		height := 0.
		_, lineHt := pdf.GetFontSize()
		for i, txt := range row {
			lines := pdf.SplitLines([]byte(txt), cols[i])
			h := float64(len(lines))*lineHt + marginCell*float64(len(lines))
			if h > height {
				height = h
			}
		}
		if pdf.GetY()+height > pageh-mbottom {
			pdf.AddPage()
			y = pdf.GetY()
		}
		for i, txt := range row {
			width := cols[i]
			pdf.Rect(x, y, width, height, "")
			pdf.MultiCell(width, lineHt+marginCell, txt, "", "", false)
			x += width
			pdf.SetXY(x, y)
		}
		pdf.SetXY(curx, y+height)
	}
	fileStr := example.Filename("Fpdf_WrappedTableCells")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
}
func ExampleFpdf_Rect ( ) { marginCell := 2. pdf := gofpdf . New ( " " , " " , " " , " " ) pdf . SetFont ( " " , " " , 12 ) pdf . AddPage ( ) pagew , pageh := pdf . GetPageSize ( ) mleft , mright , _ , mbottom := pdf . GetMargins ( ) cols := [ ] float64 { 60 , 100 , pagew - mleft - mright - 100 - 60 } rows := [ ] [ ] string { } for i := 1 ; i <= 30 ; i ++ { word := fmt . Sprintf ( " " , i , strings . Repeat ( " " , i % 100 ) ) rows = append ( rows , [ ] string { word , word , word } ) } for _ , row := range rows { curx , y := pdf . GetXY ( ) x := curx height := 0. _ , lineHt := pdf . GetFontSize ( ) for i , txt := range row { lines := pdf . SplitLines ( [ ] byte ( txt ) , cols [ i ] ) h := float64 ( len ( lines ) ) * lineHt + marginCell * float64 ( len ( lines ) ) if h > height { height = h } } if pdf . GetY ( ) + height > pageh - mbottom { pdf . AddPage ( ) y = pdf . GetY ( ) } for i , txt := range row { width := cols [ i ] pdf . Rect ( x , y , width , height , " " ) pdf . MultiCell ( width , lineHt + marginCell , txt , " " , " " , false ) x += width pdf . SetXY ( x , y ) } pdf . SetXY ( curx , y + height ) } fileStr := example . Filename ( " " ) err := pdf . OutputFileAndClose ( fileStr ) example . Summary ( err , fileStr ) }
This example demonstrate wrapped table cells
This example demonstrate wrapped table cells
// margin of top/bottom of cell // add a new page if the height of the row doesn't fit on the page // Output: // Successfully generated pdf/Fpdf_WrappedTableCells.pdf