Browse Source

Solve list items indentation

dev
Alex Puiu 2 years ago
parent
commit
06a4b6cd39
  1. 27
      app/Ingest/PDFConvertor.php

27
app/Ingest/PDFConvertor.php

@ -95,7 +95,8 @@ class PDFConvertor extends AbstractConvertor
foreach ($page as $items) {
$continuousP = '';
$firstOfText = true;
foreach ($items as $key => $p) {
if ($p->getName() == 'image') {
$imageInFooter = false;
@ -141,14 +142,15 @@ class PDFConvertor extends AbstractConvertor
if($p == '·') {
continue;
}
$addition = null;
if(isset($items[$key-1]) && $items[$key-1] == '·') {
$addition = '· ';
}
$continuousP = $continuousP . $this->handleText($p, $fonts, $addition);
$continuousP = $continuousP . $this->handleText($p, $fonts, $addition, $firstOfText);
$firstOfText = false;
$hasText = true;
}
}
@ -198,10 +200,21 @@ class PDFConvertor extends AbstractConvertor
return $html;
}
protected function handleText($p, $fonts, $addition = null)
protected function handleText($p, $fonts, $addition = null, $firstOfText = false)
{
$id = (int) $p['font'];
$font_size = $fonts[$id]['size'];
$font_color = $fonts[$id]['color'];
$font_family = $fonts[$id]['family'];
$style = '';
$style = $style . 'position: relative;';
$style = $style . "color: $font_color;";
$style = $style . "font-family: $font_family;";
$style = $style . "height: " . $p['height'] . "px;";
if($firstOfText)
$style = $style . "padding-left: " . (intval($p['left']) - 90) . "px;";
// $style = $style . "font-size: $font_size" . "px;";
if ($p->i) {
$content = '<i>' . $p->i . '</i>';
@ -219,7 +232,7 @@ class PDFConvertor extends AbstractConvertor
$tag = $this->getTag($font_size);
return '<' . $tag . '>' . $content . '</' . $tag . '>';
return '<' . $tag . ' style="' . $style . '">' . $content . '</' . $tag . '>';
}
protected function getTag($size)

Loading…
Cancel
Save