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

Wrong Table width when preview file & uploading Google Docs #216

Closed
huynhtansi opened this issue Dec 7, 2018 · 9 comments
Closed

Wrong Table width when preview file & uploading Google Docs #216

huynhtansi opened this issue Dec 7, 2018 · 9 comments

Comments

@huynhtansi
Copy link

huynhtansi commented Dec 7, 2018

Hi, dolanmiu. Thank you for awesome library.

I has a problem when creating a full-width table with code:

const table = doc.createTable(3, headers.length) table.setWidth(WidthType.PERCENTAGE, '100%')

It works fine when open in Microsoft Word, but wrong width when preview in Google Docs or Finder (I'm using MacOS).

Microsoft Word:

screen shot 2018-12-07 at 5 12 03 pm

Google Docs:

screen shot 2018-12-07 at 4 58 57 pm

Finder Preview:

screen shot 2018-12-07 at 5 12 29 pm

@dolanmiu
Copy link
Owner

dolanmiu commented Dec 7, 2018

Yes, Gogole docs, or finder is not supported

Only Microsoft Word so far

If you can figure out how to get the features working in each, that would be amazing

@carlbolduc
Copy link

I use Tab Stops to work around this, they work perfectly in both Pages and Google Docs.

@vahid18u
Copy link

vahid18u commented Mar 9, 2020

Would you please write somewhere in the documentation with bold font that this package does not support google docs ? It took more than 2 days for me to find it out and see this issue with table width. Thanks

@WilliamPeralta
Copy link

@vahid18u if you want you can add the warning on the documentation yourself and open a PR,

@baloo887
Copy link

I use Tab Stops to work around this, they work perfectly in both Pages and Google Docs.

Hi @carlbolduc , can you please explain how you use tab stops in your workaround? Everything else is working fine in my document, but tables. If your workaround works, you made my day!!

@carlbolduc
Copy link

Hi @carlbolduc , can you please explain how you use tab stops in your workaround? Everything else is working fine in my document, but tables. If your workaround works, you made my day!!

Here is an example, I first create a line like this:

const line = this.doc.createParagraph().bullet().maxRightTabStop();

I can then add content to it:

line.createTextRun('Stuff...');

And use tab stops to simulate a table:

line.createTextRun('Other stuff').tab();

@krooq
Copy link

krooq commented Feb 6, 2021

@carlbolduc I have tried the tab stops and they don't seem to work in Google docs either.. perhaps the implementation has changed since Novemebr

@carlbolduc
Copy link

@carlbolduc I have tried the tab stops and they don't seem to work in Google docs either.. perhaps the implementation has changed since Novemebr

I'm using version 5.0.0-rc4. Anything else after that broke my implementation so I stay on this version.

@dolanmiu
Copy link
Owner

dolanmiu commented Mar 5, 2021

I have found the issue, it is because you need to explicitly specify the widths

Most word processors aren't smart enough to figure out what width you want. Microsoft Word seems to be the exception and figures out the desired result nicely.

Check out this demo on how to specify widths (column widths and cell widths):

https://github.com/dolanmiu/docx/blob/master/demo/4-basic-table.ts

here are the results from different word processors using that demo:

Word 365:

Screenshot 2021-03-05 at 03 07 25

Libre Office:

Screenshot 2021-03-05 at 03 07 41

Google docs:

Screenshot 2021-03-05 at 03 07 50

In future, I will consider making docx "smarter" so it knows what width the user intends... but that seems to be a challenge in itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants