我已经在OctoberCMS中建立了一个后端列表,并且我有一个按钮来创建一个包含该列表行的PDF。每行产生一个PDF页面。但是现在我只想打印选定的行?有谁知道该怎么做?
这是我目前的代码:
public function export()
{
$lists = $this->makeLists();
$widget = reset($lists);
/* Add headers */
$headers = [];
$columns = $widget->getVisibleColumns();
foreach ($columns as $column) {
$headers[] = \Lang::get($column->label);
}
/* Add records */
$getter = $this->getConfig('export[useList][raw]', false)
? 'getColumnValueRaw'
: 'getColumnValue';
$model = $widget->prepareModel();
$results = $model->get();
$records = [];
foreach ($results as $result) {
$record = [];
foreach ($columns as $column) {
$value = $widget->$getter($result, $column);
if (is_array($value)) {
$value = implode('|', $value);
}
$record[] = $value;
}
$records[] = $record;
}
return \Renatio\DynamicPDF\Classes\PDF::loadTemplate('export-data-pdf',
['headers' => $headers, 'records' => $records])->stream('export.pdf');
}