DocumentBuilder: Image gets lost

Home Forums Open-Xml-PowerTools DocumentBuilder: Image gets lost

This topic contains 8 replies, has 2 voices, and was last updated by  Michaela 7 years, 10 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #4092

    Michaela
    Participant

    Hi,

    I use the DocumentBuilder and have the problem that an image gets lost. In one of my files I have an image that isn’t present anymore in the merged file. The image is of type “<w:drawing>”. Should the DocumentBuilder keep this image or is this not implemented?

    Thanks a lot in advance,
    Michaela

    The code of the drawing:

    <w:drawing>
    <wp:inline distT="0" distB="0" distL="0" distR="0">
    <wp:extent cx="2480945" cy="525145"/>
    <wp:effectExtent l="0" t="0" r="0" b="8255"/>
    <wp:docPr id="1" name="Bild 1"/>
    <wp:cNvGraphicFramePr>
    <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>
    </wp:cNvGraphicFramePr>
    <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
    <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
    <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
    <pic:nvPicPr>
    <pic:cNvPr id="0" name="Picture 1"/>
    <pic:cNvPicPr>
    <a:picLocks noChangeAspect="1" noChangeArrowheads="1"/>
    </pic:cNvPicPr>
    </pic:nvPicPr>
    <pic:blipFill>
    <a:blip r:embed="rId7">
    <a:extLst>
    <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
    <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0"/>
    </a:ext>
    </a:extLst>
    </a:blip>
    <a:srcRect/>
    <a:stretch>
    <a:fillRect/>
    </a:stretch>
    </pic:blipFill>
    <pic:spPr bwMode="auto">
    <a:xfrm>
    <a:off x="0" y="0"/>
    <a:ext cx="2480945" cy="525145"/>
    </a:xfrm>
    <a:prstGeom prst="rect">
    <a:avLst/>
    </a:prstGeom>
    <a:noFill/>
    <a:ln>
    <a:noFill/>
    </a:ln>
    </pic:spPr>
    </pic:pic>
    </a:graphicData>
    </a:graphic>
    </wp:inline>
    </w:drawing>
    #4093

    Eric White
    Keymaster

    Hi,

    Can you please post a test document (on dropbox or some such) and provide a link?

    DocumentBuilder should propagate all images into the assembled document, and if it does not, that would be a bug.

    Best, Eric

    #4094

    Michaela
    Participant

    Hi Eric,

    thanks for your fast response. While creating test documents for you I recognized that the bug occurs AFTER merging the documents with the DocumentBuilder. So there is no bug in your code.

    Sorry for the inconveniences.

    Best regards,
    Michaela

    #4096

    Michaela
    Participant

    Hi Eric,

    I thought that the error occurs AFTER the merging. That is not correct. I found out that the error occurs WHILE merging but I see it after it when I update all fields in the merged documents.

    So there is a bug I think. I have one document with a picture in it and a second document with a link to another document. When I merge those files the first picture becomes a link too and the picture gets lost. This isn’t correct.

    I created test documents for you and uploaded them (The linked document is not included but it’s not neccessary to show the behaviour):

    Docs

    It would be great if you could have a look at it.

    Thanks a lot in advance.

    Kind regards,
    Michaela

    • This reply was modified 7 years, 10 months ago by  Michaela.
    #4098

    Eric White
    Keymaster

    Hi Michaela,

    If I remember correctly, I didn’t address links to external documents. Such links are problematic at best, and I could not think of a scenario for DocumentBuilder where such links are important. I confess that I didn’t even think about what to do with those links, so I’m not surprised the code is broken.

    I’ll take a quick look, and see if there is an easy fix.

    Best, Eric

    #4099

    Eric White
    Keymaster

    Hi Michaela,

    I have confirmed, yes, the DocumentBuilder does not handle external links. There are security issues associated with this, as well as technical issues. Actually, I think that from a security perspective, the behavior of DocumentBuilder should be to throw an exception when it encounters one of these links.

    I would love to hear your scenario, where external links are important when using DocumentBuilder. If you have time, would you write a paragraph or two as to why they are important?

    Best, Eric

    #4101

    Michaela
    Participant

    Hi Eric,

    thanks for your fast response.
    I’m not able to write you why the exernal links are important. I’m just a developer of a software where customers can create documents and merge them (and do much more). I used the DocumentBuilder as a base and adapted all where our needs were different. So the software has to be able to merge all the customer documents independant of what they contain. And now I have to find a solution for the external links because the customer documents contain them. Throwing an exception wouldn’t be a solution for me.

    I’ll read about the external links and hope to find a way to handle them. If I’ll find a good solution I’ll let you know.

    Thanks for your support,
    Michaela

    #4103

    Eric White
    Keymaster

    Hi Michaela,

    It certainly is possible to enhance DocumentBuilder so that it handles external links. This modification can fit into the existing structure of DocumentBuilder with no issues. It probably is about 4-6 hours of work, including adding XUnit tests. You can give it a try to make the changes.

    If you want me to make those changes, I am available on a consulting basis to do so.

    Best, Eric

    #4104

    Michaela
    Participant

    Hi Eric,

    thanks for this offer. Unfortunately, I’m not allowed to pay for any support. So I have to do this on my own.

    Have a nice weekend!
    Michaela

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.