Search code examples
xquerymarklogicwordprocessingml

How can I add a header with WordProcessingML (MarkLogic Toolkit for Word)


With this code we can create a simple word document but I need to add a Header and a Footer.

let $para1 := ooxml:create-paragraph(fn:concat("Title: ",$title))
let $para2 := ooxml:create-paragraph(fn:concat("Publisher: ",$publisher))
let $paras := ($para1, $para2)

return ooxml:create-simple-docx(ooxml:document(ooxml:body($paras)))

Thanks.


Solution

  • The toolkit currently doesn't have the functionality to add headers and footers.

    But you could write your own XQuery to make it happen.

    What I'd do is add a simple header to an otherwise blank .docx.

    The Open XML SDK comes with a diff utility. Using this, you could then open the .docx with a header alongside a blank .docx using the utility, and the utility will highlight what XML has changed in which parts of the extracted .docx.

    Using this as starting place, you can use this to inform how to start writing your own function that allows you to add your own headers and footers.

    Hope this helps.