Error inserting a .docx template into a .docx template
Hi docassemble devs! I have a quick support question that has puzzled me for a few days, so I need to reach out to the community! To create the .docx templates below I'm using Word 2016 with smart quotes turned off in both places, so I can use just straight quotes. I have a main (.docx) template called "main_template.docx" whose text reads something simple like this: "Introduction Hello {{ CLIENT_NAME }}, We are Fubar Technologies. We are great. Here’s why. Statement of Work We will do work for you. It will look like this. {{p include_docx_template('managed_service_template.docx') }} Conclusion Thank you." The "Managed_service_template.docx" contains text that reads: "Managed Services We here at Fubar wish to sell Managed Services. Devices It will have nineteen endpoints deployed." When I run this through the wizard, it identifies "include_docx_template" as a variable and I answer that it should insert a template and choose the "managed_service_template.docx" template I uploaded before. I'm not 100% certain that is what I should have done. Regardless, when I run the interview, I receive this error: Error UnicodeDecodeError: 'utf8' codec can't decode byte 0xd2 in position 16: invalid continuation byte Log Traceback (most recent call last): File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/webapp/server.py", line 4262, in index interview = docassemble.base.interview_cache.get_interview(yaml_filename) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/interview_cache.py", line 35, in get_interview the_interview = interview_source.get_interview() File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 179, in get_interview return Interview(source=self) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 3589, in __init__ self.read_from(kwargs['source']) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 3706, in read_from question = Question(document, self, source=source, package=source_package, source_code=source_code) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 1819, in __init__ data['content'] += the_file.read().decode('utf8') File "/usr/share/docassemble/local/lib/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xd2 in position 16: invalid continuation byte The interview (yaml) file looks like this (as a result of using the wizard): metadata: title: Fubar Statement of Work short title: Fubar MS SoW --- question: | Client Name subquestion: | What is the full name of the client? fields: - 'Company Name': CLIENT_NAME --- mandatory: True question: | Your document is ready. subquestion: | Thank you for using this interview. buttons: - Exit: exit - Restart: restart attachments: - name: Fubar MS Statement of Work filename: Fubar_MS_Statement_of_Work docx template file: main_sow_template.docx --- template: include_docx_template subject: Template content file: managed_service_template.docx Can someone please help me identify why the UTF-8 error is being created? (Awesome product, by the way -- I think it's really wonderful) Thanks for any help, Drew
Hi Drew, The issue is that the Wizard does not currently support the use of functions like include_docx_template(). The wizard is primarily a tool for teaching the basics of docassemble. Using the include_docx_template() function is fairly advanced. The specific error you are getting comes from the fact that you are including a DOCX file where docassemble is expecting a Markdown file, but that is not important; you just need to take out that last "template" block from your YAML and include the following, which will enable the include_docx_template() function: --- modules: - docassemble.base.util --- On Mon, Mar 5, 2018 at 10:28 AM, Drew Beebe <jdbeebe@gmail.com> wrote:
Hi docassemble devs!
I have a quick support question that has puzzled me for a few days, so I need to reach out to the community! To create the .docx templates below I'm using Word 2016 with smart quotes turned off in both places, so I can use just straight quotes.
I have a main (.docx) template called "main_template.docx" whose text reads something simple like this: "Introduction
Hello {{ CLIENT_NAME }},
We are Fubar Technologies. We are great. Here’s why.
Statement of Work
We will do work for you. It will look like this.
{{p include_docx_template('managed_service_template.docx') }}
Conclusion
Thank you."
The "Managed_service_template.docx" contains text that reads: "Managed Services
We here at Fubar wish to sell Managed Services.
Devices
It will have nineteen endpoints deployed."
When I run this through the wizard, it identifies "include_docx_template" as a variable and I answer that it should insert a template and choose the "managed_service_template.docx" template I uploaded before.
I'm not 100% certain that is what I should have done.
Regardless, when I run the interview, I receive this error:
Error
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd2 in position 16: invalid continuation byte
Log
Traceback (most recent call last): File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/webapp/server.py", line 4262, in index interview = docassemble.base.interview_cache.get_interview(yaml_filename) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/interview_cache.py", line 35, in get_interview the_interview = interview_source.get_interview() File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 179, in get_interview return Interview(source=self) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 3589, in __init__ self.read_from(kwargs['source']) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 3706, in read_from question = Question(document, self, source=source, package=source_package, source_code=source_code) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 1819, in __init__ data['content'] += the_file.read().decode('utf8') File "/usr/share/docassemble/local/lib/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xd2 in position 16: invalid continuation byte
The interview (yaml) file looks like this (as a result of using the wizard):
metadata: title: Fubar Statement of Work short title: Fubar MS SoW --- question: | Client Name subquestion: | What is the full name of the client? fields: - 'Company Name': CLIENT_NAME --- mandatory: True question: | Your document is ready. subquestion: | Thank you for using this interview. buttons: - Exit: exit - Restart: restart attachments: - name: Fubar MS Statement of Work filename: Fubar_MS_Statement_of_Work docx template file: main_sow_template.docx --- template: include_docx_template subject: Template content file: managed_service_template.docx
Can someone please help me identify why the UTF-8 error is being created?
(Awesome product, by the way -- I think it's really wonderful)
Thanks for any help,
Drew
_______________________________________________ Docassemble mailing list docassemble@python.org https://mail.python.org/mm3/mailman3/lists/docassemble.python.org/
_______________________________________________ Docassemble mailing list docassemble@python.org https://mail.python.org/mm3/mailman3/lists/docassemble.python.org/
I will try that! Thank you for your help! -Drew
On Mar 5, 2018, at 10:44 AM, Jonathan Pyle <jhpyle@gmail.com> wrote:
Hi Drew,
The issue is that the Wizard does not currently support the use of functions like include_docx_template(). The wizard is primarily a tool for teaching the basics of docassemble. Using the include_docx_template() function is fairly advanced.
The specific error you are getting comes from the fact that you are including a DOCX file where docassemble is expecting a Markdown file, but that is not important; you just need to take out that last "template" block from your YAML and include the following, which will enable the include_docx_template() function:
--- modules: - docassemble.base.util ---
On Mon, Mar 5, 2018 at 10:28 AM, Drew Beebe <jdbeebe@gmail.com> wrote: Hi docassemble devs!
I have a quick support question that has puzzled me for a few days, so I need to reach out to the community! To create the .docx templates below I'm using Word 2016 with smart quotes turned off in both places, so I can use just straight quotes.
I have a main (.docx) template called "main_template.docx" whose text reads something simple like this: "Introduction
Hello {{ CLIENT_NAME }},
We are Fubar Technologies. We are great. Here’s why.
Statement of Work
We will do work for you. It will look like this.
{{p include_docx_template('managed_service_template.docx') }}
Conclusion
Thank you."
The "Managed_service_template.docx" contains text that reads: "Managed Services
We here at Fubar wish to sell Managed Services.
Devices
It will have nineteen endpoints deployed."
When I run this through the wizard, it identifies "include_docx_template" as a variable and I answer that it should insert a template and choose the "managed_service_template.docx" template I uploaded before.
I'm not 100% certain that is what I should have done.
Regardless, when I run the interview, I receive this error:
Error UnicodeDecodeError: 'utf8' codec can't decode byte 0xd2 in position 16: invalid continuation byte Log Traceback (most recent call last): File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/webapp/server.py", line 4262, in index interview = docassemble.base.interview_cache.get_interview(yaml_filename) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/interview_cache.py", line 35, in get_interview the_interview = interview_source.get_interview() File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 179, in get_interview return Interview(source=self) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 3589, in __init__ self.read_from(kwargs['source']) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 3706, in read_from question = Question(document, self, source=source, package=source_package, source_code=source_code) File "/usr/share/docassemble/local/local/lib/python2.7/site-packages/docassemble/base/parse.py", line 1819, in __init__ data['content'] += the_file.read().decode('utf8') File "/usr/share/docassemble/local/lib/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xd2 in position 16: invalid continuation byte
The interview (yaml) file looks like this (as a result of using the wizard):
metadata: title: Fubar Statement of Work short title: Fubar MS SoW --- question: | Client Name subquestion: | What is the full name of the client? fields: - 'Company Name': CLIENT_NAME --- mandatory: True question: | Your document is ready. subquestion: | Thank you for using this interview. buttons: - Exit: exit - Restart: restart attachments: - name: Fubar MS Statement of Work filename: Fubar_MS_Statement_of_Work docx template file: main_sow_template.docx --- template: include_docx_template subject: Template content file: managed_service_template.docx
Can someone please help me identify why the UTF-8 error is being created?
(Awesome product, by the way -- I think it's really wonderful)
Thanks for any help,
Drew
_______________________________________________ Docassemble mailing list docassemble@python.org https://mail.python.org/mm3/mailman3/lists/docassemble.python.org/
_______________________________________________ Docassemble mailing list docassemble@python.org https://mail.python.org/mm3/mailman3/lists/docassemble.python.org/
participants (2)
-
Drew Beebe
-
Jonathan Pyle