You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Certain documents cannot be appended when using docxcompose due to the error:
docxcompose.properties.InvalidComplexField: Complex field without end node is not supported
These particular documents we have noticed this on were generated in Word from a template. Using Word to amend/re-save the document still retains the issue. I have stripped one back and attached it as an example here: example.docx
The relevant code used is simply creating a blank document, then appending the source document into it:
Traceback (most recent call last):
File "venv\lib\site-packages\docxcompose\properties.py", line 428, in __init__
super(ComplexField, self).__init__(field_node)
File "venv\lib\site-packages\docxcompose\properties.py", line 345, in __init__
self.name, self.date_format = self._parse_fieldname_and_format()
File "venv\lib\site-packages\docxcompose\properties.py", line 377, in _parse_fieldname_and_format
self._get_fieldname_string())
File "venv\lib\site-packages\docxcompose\properties.py", line 435, in _get_fieldname_string
separate_run = self.get_separate_run()
File "venv\lib\site-packages\docxcompose\properties.py", line 471, in get_separate_run
if not self.w_p.index(separate) < self.w_p.index(self.end_run):
File "venv\lib\site-packages\docxcompose\properties.py", line 458, in end_run
raise InvalidComplexField(msg)
docxcompose.properties.InvalidComplexField: Complex field without end node is not supported
As our intended use allows users to upload documents, we need to cater for any documents that Word considers valid.
Expected behaviour
The document should be appended, and the complex field without an end node should just be ignored.
Also, if a complex field is not closed before the end of a document story, then no field shall be generated and each individual run shall be processed as if the field characters did not exist (i.e. the contents of all field code run content shall not be displayed, and the field results shall be displayed as literal text).
Version:
docxcompose 1.4.0
python-docx 0.8.11
The text was updated successfully, but these errors were encountered:
Issue:
Certain documents cannot be appended when using docxcompose due to the error:
These particular documents we have noticed this on were generated in Word from a template. Using Word to amend/re-save the document still retains the issue. I have stripped one back and attached it as an example here:
example.docx
The relevant code used is simply creating a blank document, then appending the source document into it:
And the full traceback is:
As our intended use allows users to upload documents, we need to cater for any documents that Word considers valid.
Expected behaviour
The document should be appended, and the complex field without an end node should just be ignored.
Complex fields without end nodes Word still considers as valid, if we look at the OpenXml notes at: https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.wordprocessing.fieldchar?view=openxml-2.8.1 it mentions:
Version:
The text was updated successfully, but these errors were encountered: