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

Improving copying of Word docx elements #1

Open
talkingtoaj opened this issue Sep 28, 2023 · 1 comment
Open

Improving copying of Word docx elements #1

talkingtoaj opened this issue Sep 28, 2023 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@talkingtoaj
Copy link
Owner

talkingtoaj commented Sep 28, 2023

The problem

We're using the python-docx package, which seems to be the best developed python package for ingesting and exporting docx files out there, but it is woefully lacking in some basics.

Currently our program will copy paragraphs and their formatting well, but the following are lost between being ingested from the template to the unique exams:

  • Bullet pointed lists
  • Numbered lists
  • Tables
  • Page-breaks

Desired solution

Some functions that will be called by load_in_template() and add_paragraph() which will ensure more of the Word elements are preserved.

@talkingtoaj talkingtoaj added the help wanted Extra attention is needed label Sep 28, 2023
@talkingtoaj
Copy link
Owner Author

talkingtoaj commented Sep 28, 2023

Tables

From what I have been able to tell by pausing execution in the debugger, tables are not saved within paragraphs, but instead exist in document._body.tables

Tables are inserted via document._element._insert_tbl(tbl)

Existing tables can be inspected via [Table(tbl, self) for tbl in document._element.tbl_lst]

Styles

I believe paragraph spacing is possibly being lost because styles are not copying over.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant