Exemplo n.º 1
0
func compareReferencePDF(s *RendererSuite, name string, data map[string]interface{}) {
	gofpdf.SetDefaultCatalogSort(true)
	gofpdf.SetDefaultCreationDate(time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC))
	envPath, err := utils.EnvironmentPath()

	if err != nil {
		s.T().Errorf(err.Error())
	}

	filepath := path.Join(envPath + "/renderer/templates/fixtures/" + name + ".pdf")
	file, err := ioutil.ReadFile(filepath)

	if err != nil {
		s.T().Errorf(err.Error())
	}

	template, _ := templates.LoadJsonTemplate(name, data)

	f := pdf.NewGoFpdf(template.Layout())
	renderer.Render(template, f.Document())

	buffer := bytes.NewBufferString("")

	err = gofpdf.CompareBytes(f.Bytes(buffer), file)

	if err != nil {
		s.T().Errorf(err.Error())
	}
}
Exemplo n.º 2
0
func init() {
	setRoot()
	gofpdf.SetDefaultCatalogSort(true)
	gofpdf.SetDefaultCreationDate(time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC))
}