Engine\Atomic\Files\PDF generates simple PDF tables from raw row data, CSV files, or XLS files.
use Engine\Atomic\Files\PDF;
$pdf = new PDF(
file_to: __DIR__ . '/report.pdf',
font_name: 'dejavusans',
font_size: 12
);
$pdf->raw2pdf('Sales Report', [
['Product', 'Qty', 'Price'],
['Keyboard', 10, '49.99'],
['Mouse', 25, '19.99'],
]);$pdf = new PDF(
file_to: __DIR__ . '/catalog.pdf',
file_from: __DIR__ . '/catalog.csv'
);
$pdf->file2pdf('Catalog');Supported input extensions:
csvxls
For .xls input the class internally uses Engine\Atomic\Files\XLS.
The framework also exposes CLI wrappers for direct file conversion:
php atomic file/csv2pdf <input.csv> <output.pdf> [title]
php atomic file/xls2pdf <input.xls> <output.pdf> [title]If the optional title argument is omitted, an empty title is used.
new PDF(
file_to: '/path/to/output.pdf',
file_from: '/path/to/input.csv',
font_name: 'dejavusans',
font_size: 14,
page_width: 612,
page_height: 792,
cell_padding_x: 13.0,
cell_padding_y: 7.0,
offset_percentage_x: 7,
offset_percentage_y: 5,
);The generator expects these font assets to exist in the configured font directory:
FONTS/<font>.phpFONTS/<font>.ttf
It also writes compressed font cache files into FONTS_TEMP.
- the first row is rendered like a table header
- long tables automatically continue onto new pages
- page numbers are printed at the bottom
- cell values are stringified before rendering
- only a limited number of columns fit on a page, based on page width and padding
- intended for table-like output, not general-purpose PDF layout
- only
csvand legacyxlssources are supported - boolean values are rendered as
1and0 - invalid or unreadable font files throw exceptions