How to use the docxcompose.composer.Composer function in docxcompose

To help you get started, we’ve selected a few docxcompose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 4teamwork / docxcompose / tests / test_numberings.py View on Github external
def numberings_with_zero_reference():
    composer = Composer(Document(
        docx_path("numbering_reference_to_numbering_zero.docx")))
    composer.append(Document(
        docx_path("numbering_reference_to_numbering_zero.docx")))
    return composer
github 4teamwork / docxcompose / tests / test_header.py View on Github external
def header_footer():
    composer = Composer(Document(docx_path("master.docx")))
    composer.append(Document(docx_path("header_footer_sections.docx")))
    return composer
github 4teamwork / docxcompose / tests / test_numberings.py View on Github external
def multiple_numberings():
    composer = Composer(Document(docx_path("numberings_styles.docx")))
    composer.append(Document(docx_path("numberings_styles.docx")))
    return composer
github 4teamwork / docxcompose / tests / test_numberings.py View on Github external
def mixed_numberings():
    composer = Composer(Document(docx_path("numberings_restart.docx")))
    composer.append(Document(docx_path("numberings_restart.docx")))
    return composer
github 4teamwork / docxcompose / tests / test_numberings.py View on Github external
def numberings_in_styles():
    composer = Composer(Document(docx_path("master.docx")))
    composer.append(Document(docx_path("numberings_styles.docx")))
    return composer
github 4teamwork / docxcompose / tests / test_numberings.py View on Github external
def numbering_with_paragraphs():
    composer = Composer(Document(docx_path("master.docx")))
    composer.append(Document(docx_path("numbering_with_paragraphs_in_between.docx")))
    return composer
github 4teamwork / docxcompose / tests / utils.py View on Github external
def __init__(self, master_filename, filename, *filenames):
        composer = Composer(Document(docx_path(master_filename)))
        for filename in (filename,) + filenames:
            composer.append(Document(docx_path(filename)))

        super(ComposedDocument, self).__init__(composer.doc)
github 4teamwork / docxcompose / tests / test_styles.py View on Github external
def merged_styles():
    composer = Composer(Document(docx_path("styles_en.docx")))
    composer.append(Document(docx_path("styles_de.docx")))
    return composer
github jhpyle / docassemble / docassemble_base / docassemble / base / file_docx.py View on Github external
def fix_subdoc(masterdoc, subdoc):
    """Fix the images, styles, references, shapes, etc of a subdoc"""
    composer = Composer(masterdoc) # Using docxcompose
    composer.reset_reference_mapping()

    # This is the same as the docxcompose function, except it doesn't copy the elements over.
    # Copying the elements over is done by returning the subdoc XML in this function.
    # Both sd.subdocx and the master template file are changed with these functions.
    composer._create_style_id_mapping(subdoc)
    for element in subdoc.element.body:
        if isinstance(element, CT_SectPr):
            continue
        composer.add_referenced_parts(subdoc.part, masterdoc.part, element)
        composer.add_styles(subdoc, element)
        composer.add_numberings(subdoc, element)
        composer.restart_first_numbering(subdoc, element)
        composer.add_images(subdoc, element)
        composer.add_shapes(subdoc, element)
        composer.add_footnotes(subdoc, element)