Skip to content

format page in docx on page where specific paragraph is placed #1449

Open
@mgrzeszczuk

Description

@mgrzeszczuk

I need to apply below function in document on specific page.

Function purpose is to set up specific style and margins settings. I mark this page with paragraph (see screenshot).

How I can identify this page in function to apply in only on the page with marker?

I would really appreciate your help!

def set_up_doc(doc, fund_name, section_index=0):
    # Apply styles to the specified section
    section = doc.sections[section_index]

    # Set paragraph spacing
    paragraph_format = doc.styles['Normal'].paragraph_format
    paragraph_format.space_after = Pt(0.1)

    # Set font name and size
    style = doc.styles['Normal']
    font = style.font
    font.name = 'Arial'
    font.size = Pt(9)

    # Set up margin width for the section
    section.top_margin = Cm(2.12)
    section.bottom_margin = Cm(2.01)
    section.left_margin = Cm(0.88)
    section.right_margin = Cm(1.02)


    return doc

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions