PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

Can't use multiple images

Open colejohnson66 opened this issue 3 years ago • 3 comments

If I use an image (through para.AddImage(ImageSource.FromStream("", () => /* */, 100))), any subsequent attempts to add images to other paragraphs will reuse this first loaded image. It's almost as if all references to images in the written document just use the first one.

I am using version 1.3.18 on Windows with .NET 6.0.6.

colejohnson66 avatar May 13 '22 16:05 colejohnson66

This also is a per page thing it seems. Page 1 reuses the same icons each time, but page 2 manages to load the new one. Opening the PDFs in a PDF object viewer shows each page's resource's having an XObject dictionary with only one entry (the first image).

colejohnson66 avatar May 13 '22 16:05 colejohnson66

Screenshot 2022-05-13 123416

colejohnson66 avatar May 13 '22 16:05 colejohnson66

The issue is caused by an empty string as the image name (the first parameter to ImageSource.FromStream). If I give the different images a name unique to the URI I load the Stream from, they work fine. Some kind of dedup logic is happening without considering if they're actually the same. Is this a PDF issue?

colejohnson66 avatar May 16 '22 15:05 colejohnson66