func ExampleFpdf_SetPage() {
	rnd := rand.New(rand.NewSource(0)) // Make reproducible documents
	pdf := gofpdf.New("L", "cm", "A4", "")
	pdf.SetFont("Times", "", 12)

	var time []float64
	temperaturesFromSensors := make([][]float64, 5)
	maxs := []float64{25, 41, 89, 62, 11}
	for i := range temperaturesFromSensors {
		temperaturesFromSensors[i] = make([]float64, 0)
	}

	for i := 0.0; i < 100; i += 0.5 {
		time = append(time, i)
		for j, sensor := range temperaturesFromSensors {
			dataValue := rnd.Float64() * maxs[j]
			sensor = append(sensor, dataValue)
			temperaturesFromSensors[j] = sensor
		}
	}
	var graphs []gofpdf.GridType
	var pageNums []int
	xMax := time[len(time)-1]
	for i := range temperaturesFromSensors {
		//Create a new page and graph for each sensor we want to graph.
		pdf.AddPage()
		pdf.Ln(1)
		//Custom label per sensor
		pdf.WriteAligned(0, 0, "Temperature Sensor "+strconv.Itoa(i+1)+" (C) vs Time (min)", "C")
		pdf.Ln(0.5)
		graph := gofpdf.NewGrid(pdf.GetX(), pdf.GetY(), 20, 10)
		graph.TickmarksContainX(0, xMax)
		//Custom Y axis
		graph.TickmarksContainY(0, maxs[i])
		graph.Grid(pdf)
		//Save references and locations.
		graphs = append(graphs, graph)
		pageNums = append(pageNums, pdf.PageNo())
	}
	// For each X, graph the Y in each sensor.
	for i, currTime := range time {
		for j, sensor := range temperaturesFromSensors {
			pdf.SetPage(pageNums[j])
			graph := graphs[j]
			temperature := sensor[i]
			pdf.Circle(graph.X(currTime), graph.Y(temperature), 0.04, "D")
		}
	}

	fileStr := example.Filename("Fpdf_SetPage")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
	// Output:
	// Successfully generated pdf/Fpdf_SetPage.pdf
}
// ExampleFpdf_SetPage demomstrates the SetPage() method, allowing content
// generation to be deferred until all pages have been added.
ExampleFpdf_SetPage demomstrates the SetPage() method, allowing content
generation to be deferred until all pages have been added.
// ExampleFpdf_SetPage demomstrates the SetPage () method allowing content // generation to be deferred until all pages have been added .
func ExampleFpdf_SetPage() {
	rnd := rand.New(rand.NewSource(0)) 
	pdf := gofpdf.New("L", "cm", "A4", "")
	pdf.SetFont("Times", "", 12)
	var time []float64
	temperaturesFromSensors := make([][]float64, 5)
	maxs := []float64{25, 41, 89, 62, 11}
	for i := range temperaturesFromSensors {
		temperaturesFromSensors[i] = make([]float64, 0)
	}
	for i := 0.0; i < 100; i += 0.5 {
		time = append(time, i)
		for j, sensor := range temperaturesFromSensors {
			dataValue := rnd.Float64() * maxs[j]
			sensor = append(sensor, dataValue)
			temperaturesFromSensors[j] = sensor
		}
	}
	var graphs []gofpdf.GridType
	var pageNums []int
	xMax := time[len(time)-1]
	for i := range temperaturesFromSensors {
		pdf.AddPage()
		pdf.Ln(1)
		pdf.WriteAligned(0, 0, "Temperature Sensor "+strconv.Itoa(i+1)+" (C) vs Time (min)", "C")
		pdf.Ln(0.5)
		graph := gofpdf.NewGrid(pdf.GetX(), pdf.GetY(), 20, 10)
		graph.TickmarksContainX(0, xMax)
		graph.TickmarksContainY(0, maxs[i])
		graph.Grid(pdf)
		graphs = append(graphs, graph)
		pageNums = append(pageNums, pdf.PageNo())
	}
	for i, currTime := range time {
		for j, sensor := range temperaturesFromSensors {
			pdf.SetPage(pageNums[j])
			graph := graphs[j]
			temperature := sensor[i]
			pdf.Circle(graph.X(currTime), graph.Y(temperature), 0.04, "D")
		}
	}
	fileStr := example.Filename("Fpdf_SetPage")
	err := pdf.OutputFileAndClose(fileStr)
	example.Summary(err, fileStr)
}
func ExampleFpdf_SetPage ( ) { rnd := rand . New ( rand . NewSource ( 0 ) ) pdf := gofpdf . New ( " " , " " , " " , " " ) pdf . SetFont ( " " , " " , 12 ) var time [ ] float64 temperaturesFromSensors := make ( [ ] [ ] float64 , 5 ) maxs := [ ] float64 { 25 , 41 , 89 , 62 , 11 } for i := range temperaturesFromSensors { temperaturesFromSensors [ i ] = make ( [ ] float64 , 0 ) } for i := 0.0 ; i < 100 ; i += 0.5 { time = append ( time , i ) for j , sensor := range temperaturesFromSensors { dataValue := rnd . Float64 ( ) * maxs [ j ] sensor = append ( sensor , dataValue ) temperaturesFromSensors [ j ] = sensor } } var graphs [ ] gofpdf . GridType var pageNums [ ] int xMax := time [ len ( time ) - 1 ] for i := range temperaturesFromSensors { pdf . AddPage ( ) pdf . Ln ( 1 ) pdf . WriteAligned ( 0 , 0 , " " + strconv . Itoa ( i + 1 ) + " " , " " ) pdf . Ln ( 0.5 ) graph := gofpdf . NewGrid ( pdf . GetX ( ) , pdf . GetY ( ) , 20 , 10 ) graph . TickmarksContainX ( 0 , xMax ) graph . TickmarksContainY ( 0 , maxs [ i ] ) graph . Grid ( pdf ) graphs = append ( graphs , graph ) pageNums = append ( pageNums , pdf . PageNo ( ) ) } for i , currTime := range time { for j , sensor := range temperaturesFromSensors { pdf . SetPage ( pageNums [ j ] ) graph := graphs [ j ] temperature := sensor [ i ] pdf . Circle ( graph . X ( currTime ) , graph . Y ( temperature ) , 0.04 , " " ) } } fileStr := example . Filename ( " " ) err := pdf . OutputFileAndClose ( fileStr ) example . Summary ( err , fileStr ) }
ExampleFpdf_SetPage demomstrates the SetPage() method, allowing content
generation to be deferred until all pages have been added.
ExampleFpdf_SetPage demomstrates the SetPage () method allowing content generation to be deferred until all pages have been added .
// Make reproducible documents //Create a new page and graph for each sensor we want to graph. //Custom label per sensor //Custom Y axis //Save references and locations. // For each X, graph the Y in each sensor. // Output: // Successfully generated pdf/Fpdf_SetPage.pdf