kessemtini omar
kessemtini omar

Reputation: 21

Flying saucer/OpenPdf same string html content but different byte[]

I'm using flying saucer pd with openpdf to gnerate pdf. I generate the pdf from an htm file using thymleaf 3.

All works fine, but not the test.

My idea was to create a testing method that generate a pdf file ... after that i convert the ButeArrayStream to a byte[] ... and finally test the byte[] generated with the byte[] i got from a previous compilation.

But, i found out that ItextRenderer.createPdf(htmlContent) generate different byte[] each time.

Is it normal ? is there a way to get the same byte[] each time ?

Upvotes: 2

Views: 988

Answers (1)

Amedee Van Gasse
Amedee Van Gasse

Reputation: 7634

It is normal. If you want to test your document, you need to do a structural or visual comparison, not a byte comparison. To have an idea on how to do that, have a look at the CompareTool class of iText 7 (OpenPdf is a fork of an older version of iText, so the API may seem familiar).

Upvotes: 2

Related Questions