Headless exporting to pdf with specific formatting

i work on converting excel to pdf using libreoffice. i need to do this via php using libreoffice in headless mode.

to get exporting results i need, i did the following settings for exporting in GUI:

  1. in format - page style, on tab ‘page’ i set ‘page’ to landscape mode
  2. in format- page style, on tab ‘page’ i set ‘page’ margins to 0.10
  3. in format - page style, on tab ‘sheet’ i set ‘scaling mode’ to ‘fit print ranges to witdth/height’, and set width in pages = 1, and unselected height in pages (i need content to fit horizontally on one page
  4. in format - page style, on tab ‘sheet’ i checked print ‘grid’ and ‘zero values’, everything else is unchecked - so that resulting pdf has table grid
  5. in the excel itself, i changed column width manually so that longer text is all visible, because if it is overflowed horizontally or vertically, it is being cut off when exporting to pdf

From what i understood, there are no possibility to do this directly via cli, and the only options (if that’s even possible) - to use macros.

However, i don’t quite understand how to attach a macro and use it in headless mode
Any help would be appreciated