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

Feature: Replace text in text-boxes #36

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

t-oster
Copy link
Contributor

@t-oster t-oster commented Sep 22, 2022

Hi,

this is my attempt at thombergs/docx-stamper#97. The approaches from thombergs/docx-stamper#97 did not quite work, because they broke some tests.

I added it in a more conservative way: I search through all P elements in the document and find those, which are children of Text-Boxes. This is added as an additional helper method ParagraphUtil.getAllTextBoxes(document).

In the CoordinatesWalker.walk() method I run walkContent on those elements after the other content is processed. This way I did not break any tests. I added a test document with two simple text-boxes and it works.

Things I noticed:

  • My ParagraphUtil.getAllTextBoxes(document) finds all text-box paragraphs (in the test-document) twice with different parents. However this doesn't seem to be a problem (I guess the text is processed the first time and the second time it already contains the processed text)
  • I did not try this with recursion or start/end comments.

However since the current implementation just ignores text-boxes this is IMHO safe to add, because it just adds functionality, which may not work in complex cases.

@caring-coder caring-coder linked an issue Sep 23, 2022 that may be closed by this pull request
@caring-coder caring-coder linked an issue Sep 23, 2022 that may be closed by this pull request
@caring-coder caring-coder merged commit 2100d6c into verronpro:master Sep 23, 2022
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

Successfully merging this pull request may close these issues.

Variables in text boxes do not get replaced
2 participants