Centre tables on a page

Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
dbutch
Posts: 41
Joined: Wed Aug 14, 2019 9:16 am

Centre tables on a page

Post 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.
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: Centre tables on a page

Post 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
dbutch
Posts: 41
Joined: Wed Aug 14, 2019 9:16 am

Re: Centre tables on a page

Post 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.
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: Centre tables on a page

Post 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
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: Centre tables on a page

Post 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
Post Reply