I've stumbled across this bug when adding watermarks to my document programmatically. The idea is that I have two pdfs: the input.pdf and the watermark.pdf
The first page of watermark.pdf is used as a watermark for input.pdf.
When extracting the first page with the following code
var waterDoc = watermarkFile.Document; var page = waterDoc.Pages; watermark = page.ToXObject(doc);
it sadly is missing many of the used XObjects. The reason for this is, that
form.Resources = (Resources)(context.Equals(Document) ? Resources // Same document: reuses the existing resources. : Resources.Clone(context) // Alien document: clones the resources. );
in Page.ToXObject decides that the context ist identical, although context ist from input.pdf while document is from watermark.pdf.
I guess the problem here is that Document does not have its own Equals() Method and so the parent PdfObjectWrapper is called, which does but a very very basic compare.