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

Table too wide for document #11

Closed
cpbotha opened this issue Feb 5, 2014 · 4 comments
Closed

Table too wide for document #11

cpbotha opened this issue Feb 5, 2014 · 4 comments

Comments

@cpbotha
Copy link

cpbotha commented Feb 5, 2014

I'm creating a docx containing a table with three columns, some of them containing 80 characters of text.

When I open the doc, the first column of the table is wider than the page. When I select table properties and set the width to relative and 100%, it fits the whole table nicely and wraps the text where necessary.

Is there a way to specify the width of the created table to 100% relative?

At the moment I'm digging around in docx/oxml/table.py and using this http://www.docx4java.org/forums/pdf-output-f27/pdf-conversion-table-width-t1233.html as a hint, but pointers would be greatly appreciated!

@scanny
Copy link
Contributor

scanny commented Feb 5, 2014

Hi Charl, what I would do would be to see what Word does when you set it the way you want and try to duplicate that.

One way to do that is to use opc-diag to browse a before and after version of the .docx file. The command would be something like this:

$ opc diff-item before.docx after.docx document.xml

I expect the difference comes down to a few elements and/or attributes in the table properties XML.

If you can narrow it down to those specifics I can give you a couple lines of code to put that XML in place. You can wrap that in a function or method and call it in the right spot in your code.

Once we have it working we can noodle a bit what the API for doing it directly from the library wants to look like and then we can add it to the backlog.

Want to give that a shot?

@cpbotha
Copy link
Author

cpbotha commented Feb 5, 2014

Thanks for responding so quickly!

I'd like to try that. However, here I have only LibreOffice 4.1.4.2 to test the DOCX, and that generates a whole lot of extra code in the resultant file. Tomorrow at work I hope to be able to test with a real-deal Word and look at the differences.

@cpbotha
Copy link
Author

cpbotha commented Feb 6, 2014

A kind colleague just checked with MS Word and there it renders correctly.

Sorry for the disturbance. Hopefully this closed issue report will help other LibreOffice users in the future. :)

Thanks again,
Charl

@cpbotha cpbotha closed this as completed Feb 6, 2014
@scanny
Copy link
Contributor

scanny commented Feb 6, 2014

No worries, thanks Charl :)

ryanamannion referenced this issue in BlackBoiler/python-docx Sep 8, 2021
prepend and append comment elements instead of inserting them inside <w:r>
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

No branches or pull requests

2 participants