Page 1 of 1

Centre tables on a page

Posted: Wed Feb 05, 2020 6:57 am
by dbutch
Is there a way to centre an entire table on a page in a PDF?
I can get the contents to centre in the cells, but am unable to centre the whole table on the page.

Thanks.

Re: Centre tables on a page

Posted: Wed Feb 05, 2020 11:48 am
by julien_lacour
Hello Duncan,

You should be able to center your table using the following selector:

Code: Select all

table {
    margin-right: 30%;
    margin-left: 30%;
}
Feel free to modify the values to fit your needs.

There is also an issue on our side to add the 'auto' support for table margins but it will be in a future release.

Regards,
Julien

Re: Centre tables on a page

Posted: Fri Feb 07, 2020 6:03 am
by dbutch
Hi Julien,

The CSS selector works, however it compresses all tables to fit within those margins.
There is also an issue on our side to add the 'auto' support for table margins but it will be in a future release.
Does this mean there is not an option currently for tables to automatically size and adjust their layout (as per https://www.oxygenxml.com/doc/versions/ ... aid-title5), and be centred on the page?

Thanks.

Re: Centre tables on a page

Posted: Fri Feb 07, 2020 3:21 pm
by julien_lacour
Hello Duncan,

Unfortunately, we do not have an option to center the tables automatically inside a page, this should be done by

Code: Select all

table {
    margin-right: auto;
    margin-left: auto;
}
But this is not yet supported by the Apache FOP engine used inside Oxygen PDF Chemistry.
Until we add this support you can use the percentage solution (updated to your needs) with or without the automatic table layout.
Please note that the table-layout CSS property sets the algorithm used to lay out <table> cells, rows, and columns. Not its position in the document.

Regards,
Julien

Re: Centre tables on a page

Posted: Thu May 21, 2020 12:11 pm
by julien_lacour
Hello Duncan,

Starting with Oxygen 22.1, you can center tables inside a page.
For more informations, please check the documentation.

Regards,
Julien