func ExampleFpdf_ClipRect() {
	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 <= 50; i++ {
		word := fmt.Sprintf("%d:%s", i, strings.Repeat("A", i%100))
		rows = append(rows, []string{word, word, word})
	}

	for _, row := range rows {
		_, lineHt := pdf.GetFontSize()
		height := lineHt + marginCell

		x, y := pdf.GetXY()
		// add a new page if the height of the row doesn't fit on the page
		if y+height >= pageh-mbottom {
			pdf.AddPage()
			x, y = pdf.GetXY()
		}
		for i, txt := range row {
			width := cols[i]
			pdf.Rect(x, y, width, height, "")
			pdf.ClipRect(x, y, width, height, false)
			pdf.Cell(width, height, txt)
			pdf.ClipEnd()
			x += width
		}
		pdf.Ln(-1)
	}
	fileStr := example.Filename("Fpdf_ClippedTableCells")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
	// Output:
	// Successfully generated pdf/Fpdf_ClippedTableCells.pdf
}
// This example demonstrate Clipped table cells
This example demonstrate Clipped table cells
// This example demonstrate Clipped table cells
func ExampleFpdf_ClipRect() {
	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 <= 50; i++ {
		word := fmt.Sprintf("%d:%s", i, strings.Repeat("A", i%100))
		rows = append(rows, []string{word, word, word})
	}
	for _, row := range rows {
		_, lineHt := pdf.GetFontSize()
		height := lineHt + marginCell
		x, y := pdf.GetXY()
		if y+height >= pageh-mbottom {
			pdf.AddPage()
			x, y = pdf.GetXY()
		}
		for i, txt := range row {
			width := cols[i]
			pdf.Rect(x, y, width, height, "")
			pdf.ClipRect(x, y, width, height, false)
			pdf.Cell(width, height, txt)
			pdf.ClipEnd()
			x += width
		}
		pdf.Ln(-1)
	}
	fileStr := example.Filename("Fpdf_ClippedTableCells")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
}
func ExampleFpdf_ClipRect ( ) { 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 <= 50 ; i ++ { word := fmt . Sprintf ( " " , i , strings . Repeat ( " " , i % 100 ) ) rows = append ( rows , [ ] string { word , word , word } ) } for _ , row := range rows { _ , lineHt := pdf . GetFontSize ( ) height := lineHt + marginCell x , y := pdf . GetXY ( ) if y + height >= pageh - mbottom { pdf . AddPage ( ) x , y = pdf . GetXY ( ) } for i , txt := range row { width := cols [ i ] pdf . Rect ( x , y , width , height , " " ) pdf . ClipRect ( x , y , width , height , false ) pdf . Cell ( width , height , txt ) pdf . ClipEnd ( ) x += width } pdf . Ln ( - 1 ) } fileStr := example . Filename ( " " ) err := pdf . OutputFileAndClose ( fileStr ) example . Summary ( err , fileStr ) }
This example demonstrate Clipped table cells
This example demonstrate Clipped 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_ClippedTableCells.pdf