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

How to make the content after patchDocument have the same style as the key? #2293

Closed
KaneOne opened this issue Aug 9, 2023 · 2 comments · Fixed by #2387
Closed

How to make the content after patchDocument have the same style as the key? #2293

KaneOne opened this issue Aug 9, 2023 · 2 comments · Fixed by #2387
Labels

Comments

@KaneOne
Copy link

KaneOne commented Aug 9, 2023

As shown in the screenshot below, I changed the font size of the paragraph, when using patchDocument, the replaced content does not use the font and style of the key but uses the default font instead. How can I set it so that the replaced content has the same style as the key? Thank you.
image

image

@dolanmiu dolanmiu added the bug label Aug 10, 2023
@KaneOne
Copy link
Author

KaneOne commented Sep 4, 2023

Hi, @dolanmiu

May I ask if there is a plan to fix this bug? I hope to use the docx library in my project. Thank you.

wilkmaia added a commit to wilkmaia/docx that referenced this issue Oct 18, 2023
There were scenarios in which patching a document would result in loss
of style for the template runs and, possibly, their right-adjacent run
as well (post-splitting). That was due to the run style elements not
being added to the newly created runs.

This commit addresses this issue by introducing a new, optional, flag
for the `patchDocument` function: `keepOriginalStyles`. It defaults to
`false` (current behavior) and, when `true`, ensures that there is no
loss of styling.

This should address dolanmiu#2293.
@KaneOne
Copy link
Author

KaneOne commented Nov 16, 2023

Working very well, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants