Errors.
var (
ErrRenderNotSupported = errors.New("rendering PDF files is not supported on this system")
)
func CompareDictionariesDeep(d1, d2 *core.PdfObjectDictionary) bool
CompareDictionariesDeep does a deep comparison of `d1` and `d2` and returns true if equal.
func CompareImages(img1, img2 image.Image) (bool, error)
CompareImages compares the specified images at pixel level.
func ComparePNGFiles(file1, file2 string) (bool, error)
ComparePNGFiles compares the specified PNG files.
func CopyFile(src, dst string) error
CopyFile copies the `src` file to `dst`.
func HashFile(file string) (string, error)
HashFile generates an MD5 hash from the contents of the specified file.
func ParseIndirectObjects(rawpdf string) (map[int64]core.PdfObject, error)
ParseIndirectObjects parses a sequence of indirect/stream objects sequentially from a `rawpdf` text. Great for testing.
func ReadPNG(file string) (image.Image, error)
ReadPNG reads and returns the specified PNG file.
func RenderPDFToPNGs(pdfPath string, dpi int, outpathTpl string) error
RenderPDFToPNGs uses ghostscript (gs) to render the specified PDF file into a set of PNG images (one per page). PNG images will be named xxx-N.png where N is the number of page, starting from 1.
func RetryHelper(t *testing.T, maxAttempts int, delay time.Duration, fn func(rt ExtendedTestingT)) error
RetryHelper executes the provided function `fn` up to `maxAttempts` times with a delay between attempts. It captures any errors generated by `require` and logs them. If all attempts fail, it returns an error indicating that the maximum attempts were exceeded.
func RunRenderTest(t *testing.T, pdfPath, outputDir, baselineRenderPath string, saveBaseline bool)
RunRenderTest renders the PDF file specified by `pdfPath` to the `outputDir` and compares the output PNG files to the golden files found at the `baselineRenderPath` location. If the specified PDF file is new (there are no golden files) and the `saveBaseline` parameter is set to true, the output render files are saved to the `baselineRenderPath`.
ExtendedTestingT combines require.TestingT with logging methods.
type ExtendedTestingT interface {
require.TestingT // Embeds Errorf and FailNow
Logf(format string, args ...interface{})
Helper()
}