jferard / fastods

A very fast and lightweight (no dependency) library for creating ODS (Open Document Spreadsheet, mainly for Calc) files in Java. It's a Martin Schulz's SimpleODS fork
GNU General Public License v3.0
35 stars 6 forks source link

Set page margin and page size #206

Closed chrismaster closed 3 years ago

chrismaster commented 3 years ago

Is there a way to set the page margin (top, bottom, left right, footer, header) and page size (mm,mm) ?

jferard commented 3 years ago

In the tutorial, you have an example of how to set a page style.

Without comments:

    final PageStyle pageStyle = PageStyle.builder("page-style").header(header).footer(footer).build();
    final TableStyle tableStyle = TableStyle.builder("table-style").pageStyle(pageStyle).build();
    table.setStyle(tableStyle);

The PageStyleBuilder class (first line) has the following methods:

Try something like:

    final PageStyle pageStyle = PageStyle.builder("page-style").allMargins(SimpleLength.cm(4)).paperFormat(PaperFormat.A3).build();
    final TableStyle tableStyle = TableStyle.builder("table-style").pageStyle(pageStyle).build();
    table.setStyle(tableStyle);
jferard commented 3 years ago

Guess it's okay.