MainDocumentPart.Annotation returns null

Home Forums Open-Xml-Sdk MainDocumentPart.Annotation returns null

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Eric White 7 years, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3611

    Manu_TR
    Participant

    Hello,

    Here is the code snippet where it is returning null.

    XDocument doc = wordDoc.MainDocumentPart.GetXDocument();

    public static XDocument GetXDocument(this OpenXmlPart part)
    {
    XDocument xdoc = part.Annotation<XDocument>();
    }

    Could someone please tell me why am i getting xdoc as null? this is veru urgent. Thanks in advance

    #3638

    Eric White
    Keymaster

    Hello,

    Storing XDocument objects as an annotation on the part is a common technique – it is the approach that Open-Xml-PowerTools uses. Where did you get this code? Are you using Open-Xml-PowerTools?

    Cheers

    #3646

    Manu_TR
    Participant

    yes, I am using Open-Xml-PowerTools.

    #3673

    Eric White
    Keymaster

    I don’t have enough information in order to develop a theory about your issue. Why are you writing code to get the annotation, instead of calling GetXDocument on the part?

    A good way to start is from one of the existing, working Open-Xml-PowerTools examples. They work out-of-the-box, and then you make modifications to the code, customizing to your scenario.

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

You must be logged in to reply to this topic.