Brant

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Issue with document merging and maintaing Page orientation #7534

    Brant
    Participant

    Orientation is stored in the section properties element <w:sectPr>. For DocumentBuilder, you set keepSections to true.

    public Source(WordprocessingDocument source, int start, int count, bool keepSections);

    in reply to: Open Xml PowerTool to merge the two content in same word #7515

    Brant
    Participant

    Source has another constructor that allows you to specify the child elements of <w:body> to include in the final document.

    public Source(WordprocessingDocument source, int start, int count, bool keepSections);

    This is from Eric’s blog: How to Control Sections when using OpenXml.PowerTools.DocumentBuilder

    A super-short summary of how you use DocumentBuilder: to assemble a new document, you open any number of source Open XML WordprocessingML documents, then assemble a List<OpenXml.PowerTools.Source>, where members of the list are Source objects that you construct, passing a number of parameters. There are three overloads of the Source constructor:

    public Source(WordprocessingDocument source, bool keepSections)
    public Source(WordprocessingDocument source, int start, bool keepSections)
    public Source(WordprocessingDocument source, int start, int count, bool keepSections)

    The first parameter is the open WordprocessingML source document.

    If you use the first overload, then the entire source document is copied (along with all dependencies) to the destination document. If you use the second overload, you can specify a starting paragraph (technically the starting child element of the w:body element), and the document from that point on is copied to the destination document. The third overload allows you to pluck just a subsection of the source document for inclusion in the destination document.

    The last parameter is always a bool, keepSections. You can specifically control how sections are copied to the newly-built document using the keepSections argument.

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