Closed joewestcott closed 5 years ago
On second inspection, I think I've found a better way to do this. Please hold off on merging for now...!
@joewestcott -- will do, thanks for the tip-off.
I've placed my proposed breaking changes in another PR. This one should be fine!
Currently, it's possible to end up with the same image inserted into the final PDF multiple times.
This is possible if you register the same image under two different keys (unlikely), but it's also possible when trying to use the same image in multiple templates. The CreateTemplate example actually attempts this and the image is written into the PDF twice. After this
change the filesize is reduced by about 20%.
It accomplishes this by storing the SHA-1 hash of each inserted image, and re-uses the objects ID if it's found. I've also committed my comments in a bunch of places from trying to understand the codebase.