mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 02:38:50 +02:00
Allow to generate multiple labels at once (multiple pages in 1 PDF file).
This commit is contained in:
parent
4c5820ee22
commit
e89cc4bb01
12 changed files with 389 additions and 228 deletions
|
@ -38,11 +38,23 @@ class LabelHTMLGenerator
|
|||
$this->replacer = $replacer;
|
||||
}
|
||||
|
||||
public function getLabelHTML(LabelOptions $options, object $element): string
|
||||
public function getLabelHTML(LabelOptions $options, array $elements): string
|
||||
{
|
||||
if (empty($elements)) {
|
||||
throw new \InvalidArgumentException('$elements must not be empty');
|
||||
}
|
||||
|
||||
$twig_elements = [];
|
||||
foreach ($elements as $element) {
|
||||
$twig_elements[] = [
|
||||
'element' => $element,
|
||||
'lines' => $this->replacer->replace($options->getLines(), $element)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->twig->render('LabelSystem/labels/base_label.html.twig', [
|
||||
'meta_title' => $this->getPDFTitle($options, $element),
|
||||
'lines' => $this->replacer->replace($options->getLines(), $element),
|
||||
'meta_title' => $this->getPDFTitle($options, $elements[0]),
|
||||
'elements' => $twig_elements,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue