Reusing the same image multiple times but store only once in the PDF
-
Is it possible to reuse resources multiple times inside of a PDF in order to not bloat the PDF with multiple copies of the same image? Also, I need this to work within SVG tags because I'm overlaying the images with svg graphics.
My use case:
- Show one large original image on one page
- Show multiple different crops (viewbox) of the same image inside of svg elements on other pages
Here are some idéas that I don't think will fly:
-
define the image as an svg resource with
<defs>
and use it multiple times with<use>
. I need many separate svg tags and defs is only scoped to the current svg parent, so this won't work. -
load the image as a background image defined in a css class. The background image concept does not seem to work for images inside of svgs.
Any other suggestions?
My fallback solution will be to have a server generate all the croped jpg images to minimize the size. Viewbox only hides parts of the image, but the complete image is still stored in the pdf multiple times.