#53 Page.ToXObject context comparison

0.1.2.1
closed-fixed
None
1
2015-03-09
2013-10-28
No

Hi again,

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[0];
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.

Kind regards,
Andreas

Discussion

  • Andreas Pinter

    Andreas Pinter - 2013-10-28

    Hi again,

    probably the PdfObjectWrapper should consider checking against the Document context in general?
    Two objects with an identical ID and even identical content are not identical if they are from different documents, are they?

    Kind regards,
    Andreas

     
  • Stefano Chizzolini

    Fixed on 0.1.2-Fix branch (rev 157) and 0.2.0 trunk (rev 158). Reference equality was previously fixed on 0.1.2-Fix branch (rev 119) and 0.2.0 trunk (rev 118)

    thank you

     
  • Stefano Chizzolini

    • status: open --> closed-fixed
    • assigned_to: Stefano Chizzolini
    • Group: v1.0_(example) --> 0.1.2.1
    • Priority: 5 --> 1
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks