Beispiel #1
0
func docWriter(pdf *gofpdf.Fpdf, idx int) *pdfWriter {
	pw := new(pdfWriter)
	pw.pdf = pdf
	pw.idx = idx
	if pdf.Ok() {
		var err error
		fileStr := fmt.Sprintf("%s/pdf/tutorial%02d.pdf", cnGofpdfDir, idx)
		pw.fl, err = os.Create(fileStr)
		if err != nil {
			pdf.SetErrorf("Error opening output file %s", fileStr)
		}
	}
	return pw
}
Beispiel #2
0
func tutorialSummary(f *gofpdf.Fpdf, fileStr string) {
	if f.Ok() {
		fl, err := os.Create(fileStr)
		defer fl.Close()
		if err == nil {
			f.Output(fl)
		} else {
			f.SetError(err)
		}
	}
	if f.Ok() {
		fmt.Printf("Successfully generated %s\n", fileStr)
	} else {
		errPrintf("%s\n", f.Error())
	}
}