Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mgrzeszczuk opened this issue Nov 21, 2024 · 0 comments
Open

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

mgrzeszczuk opened this issue Nov 21, 2024 · 0 comments

Comments

@mgrzeszczuk
Copy link

mgrzeszczuk commented Nov 21, 2024

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

@mgrzeszczuk mgrzeszczuk changed the title format page in in docx on page where specific paragraph is placed format page in docx on page where specific paragraph is placed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant