Skip to content

Commit

Permalink
malformed tables bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalpospiech committed Feb 1, 2019
1 parent 51d4790 commit 790d8c6
Show file tree
Hide file tree
Showing 8 changed files with 398 additions and 120 deletions.
222 changes: 222 additions & 0 deletions examples/Invoice.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
<div data-header style="padding-top:10px; padding-left:30px; padding-right:30px">
<div>
<table style="font-family:'DejaVu Sans';font-size:10px;width:100%;">
<tbody>
<tr>
<td style="text-align:left;width:50%;">VAT invoice number F-I1</td>
<td style="text-align:right;width:50%;">Issued date 2019-02-16</td>
</tr>
</tbody>
</table>
</div>
</div>
<div data-footer style="padding-bottom:10px; padding-left:30px; padding-right:30px">
<table style="font-family:'DejaVu Sans';font-size:8px;width:100%;">
<tbody>
<tr>
<td style="width:50%;">Powered by YetiForceCRM</td>
<td style="text-align:right;width:50%;">{p}/{a}</td>
</tr>
</tbody>
</table>
</div>
<table cellspacing="0"
style="border-collapse:collapse;font-family:'DejaVu Sans';font-size:9px;margin-bottom:6px;width:100%;">
<thead>
<tr>
<th style="text-align:center;width:25%;">Issued date</th>
<th style="text-align:center;width:25%;">Sale date</th>
<th style="text-align:center;width:25%;">Due date</th>
<th style="text-align:center;width:25%;">Payment method</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;text-align:center;">2019-02-16</td>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;text-align:center;">2019-02-10</td>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;text-align:center;">2019-02-11</td>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;text-align:center;">Bank transfer</td>
</tr>
</tbody>
</table>
<table cellspacing="0"
style="border-collapse:collapse;font-family:'DejaVu Sans';font-size:9px;line-height:1.1em;text-align:center;width:100%;">
<thead>
<tr>
<th style="font-size:9px;width:50%;">Seller</th>
<th style="font-size:9px;width:50%;">Purchaser</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;line-height:1.2;vertical-align:top;">
YetiForce Sp. z o.o. <br>
<br>
<br>
Vat ID:
</td>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;line-height:1.2;vertical-align:top;">
Agro-Ferm Sp. z o.o.<br>
ul. Wiosenna 6940<br>
59-621 Zielonka<br>
Vat ID: 6547663360
</td>
</tr>
</tbody>
</table>
<div style="font-family:'DejaVu Sans';margin-top:12px;text-align:center;">
<h3>VAT invoice number: F-I1</h3>
</div>
<div style="font-family:'DejaVu Sans';font-size:8px;margin-bottom:20px;margin-left:0px;margin-right:0px;margin-top:10px;">
<table style="width:100%;border-collapse:collapse;">
<thead>
<tr>
<th style="padding:0px 4px;text-align:center;">Item name</th>
<th style="padding:0px 4px;text-align:center;">Quantity</th>
<th style="padding:0px 4px;text-align:center;">Unit price</th>
<th style="padding:0px 4px;text-align:center;">Net</th>
<th style="padding:0px 4px;text-align:center;">Gross</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border:1px solid #ddd;padding:0px 4px;"><strong><a
class="modCT_Services showReferenceTooltip js-popover-tooltip--record"
href="index.php?module=Services&view=Detail&record=581" title="Service">transferowanie pliki – FTP,
P2P;</a></strong><br/> W takim Litwinka tylko się dziś toczy się szczyci i żądał. I ogląda czule, jako
wierzchołki i hec! od płaczącej matki pod las wiąże w bieg chybkim był żonaty a Praga już jej talerzów,
nie ma żądło w wiecznej wiośnie pachnące kwitną lasy.
</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">868</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">96186.6 €</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">22729.8 €</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">60935.1 €</td>
</tr>
<tr>
<td style="border:1px solid #ddd;padding:0px 4px;"><strong><a
class="modCT_Products showReferenceTooltip js-popover-tooltip--record"
href="index.php?module=Products&view=Detail&record=560" title="Product">Steca Power Tarom12/24/48V
55-140A</a></strong><br/>Hreczecha. Tu Kościuszko w drewnianej szafie poznał z żoną i objął
gospodarstwo. przyrzekł na piersiach, przydawając zasłony sukience.
</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">173</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">3508.3 €</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">76176.1 €</td>
<td style="border:1px solid #ddd;padding:0px 4px;text-align:right;">32199.2 €</td>
</tr>
</tbody>
<tfoot>
<tr>
<th style="padding:0px 4px;text-align:right;"></th>
<th style="padding:0px 4px;text-align:right;"></th>
<th style="padding:0px 4px;text-align:right;"></th>
<th style="padding:0px 4px;text-align:right;">98905.9 €</th>
<th style="padding:0px 4px;text-align:right;">93134.3 €</th>
</tr>
</tfoot>
</table>
</div>
<table cellspacing="0"
style="border-collapse:collapse;font-family:'DejaVu Sans';font-size:8px;margin:0px 0px 20px 0px;width:100%;">
<tbody>
<tr>
<td style="vertical-align:top;width:50%;">
<table style="width:100%;vertical-align:top;border-collapse:collapse;border:1px solid #ddd;">
<thead>
<tr>
<th colspan="2" style="font-weight:bold;padding:0px 4px;">Tax summary</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;font-weight:bold;padding:0px 4px;">Amount</td>
<td style="text-align:right;font-weight:bold;padding:0px 4px;">0 €</td>
</tr>
</tbody>
</table>
</td>
<td style="vertical-align:top;width:50%;">
<table style="width:100%;vertical-align:top;border-collapse:collapse;">
<thead>
<tr>
<th style="padding:0px 4px;font-weight:bold;">Discount summary</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding:0px 4px;text-align:right;font-weight:bold;border:1px solid #ddd;">59751.4 €</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table cellspacing="0" style="border-collapse:collapse;font-family:'DejaVu Sans';font-size:8px;width:100%;">
<tbody>
<tr>
<td style="vertical-align:top;width:50%;">
<table style="border-collapse:collapse;width:100%;border:1px solid #ddd;">
<thead>
<tr>

<th colspan="2" style="padding:0px 4px;text-align:center;">
<strong>Currency summary</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="padding:0px 4px;font-weight:bold;">Amount</td>
<td style="text-align:right;padding:0px 4px;">0 zł</td>
</tr>
</tbody>
</table>
</td>
<td style="vertical-align:top;width:50%;">
<table cellspacing="0" style="border-collapse:collapse;width:100%;">
<thead>
<tr>
<th style="font-size:10px;">Total</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;font-size:12px;font-weight:bold;text-align:center;">
93134.3 zł
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table cellspacing="0"
style="border-collapse:collapse;font-family:'DejaVu Sans';font-size:9px;margin:20px 0px;text-align:left;width:100%;">
<thead>
<tr>
<th style="text-align:left;">
<div style="margin-left:4px;">Comments</div>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="border-color:#dddddd;border-style:solid;border-width:1px;padding:10px;">Niemnem rozciągnionych. Do
zobaczenia! tak się w drobne strączki białe dziwnie ozdabiał głowę, bo tak i kiedy karę na waszych
polowaniach łowił? Piękna byłaby sława, a ubiór zwrócił oczy. wszyscy za zającami nie mające kłów, rogów,
pazurów zostawiano dla skończenia dawnego z Tadeuszem idą pod strzechą zmieścić się zatrudniał i opisuję, bo
tak piękny pies faworytny Żeby nie ma dotąd pierwsze na ambonie. Nauka dawną była, szło o kusego charta
którego posiadaniem pan Sędzia tuż nad nim w tym mieczem wypędzi z opieki panicz przed nim stał kwestarz,
Sędzia Podkomorzego zdał się długo dumał, nim szedł z dziecinną radością pociągnął za mych czasów w dłonie
jak biały ptak zleciała z liczby pługów orzących wcześnie łany ogromne ugoru czarnoziemne, zapewne należne
do Polski trzech mocarzów albo bierze. Nawet strony przeciwne wezwiemy na naukę młodzież lepsza, ale nigdzie
nie jedli. Stojąc i mimo całą rodzina pańska, jak szli na szańcach Pragi, na prawo, koziołka, z chleba
gałeczki trzy z synowcem witania: dał mu z las drogi i chołodziec litewski milcząc żwawo jedli. , choć
świadka nie rozwity, lecz straszny na wieczerzę. Rykow.
</td>
</tr>
</tbody>
</table>
<div style="font-family:'DejaVu Sans';font-size:8px;text-align:left;">Issued by: YetiForce Demo</div>
8 changes: 8 additions & 0 deletions examples/Invoice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

$loader = require '../vendor/autoload.php';

$document = (new YetiForcePDF\Document())->init();
$document->loadHtml(file_get_contents('Invoice.html'));
$pdfFile = $document->render();
file_put_contents('Invoice.pdf', $pdfFile);
Binary file modified examples/PagesTables.pdf
Binary file not shown.
Binary file modified examples/helloWorld.pdf
Binary file not shown.
75 changes: 60 additions & 15 deletions examples/wordWrap.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,73 @@
<div style="display:inline;border:1px solid #000000;">
test
<div style="display:inline;">test2</div>
<div style="display:inline;">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius dolorum efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros accommodare sed. Decore scripserit definitiones et pri, at duo purto sale quidam.
test
<div style="display:inline;">test2</div>
<div style="display:inline;">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius
dolorum efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros
accommodare sed. Decore scripserit definitiones et pri, at duo purto sale quidam.

Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci et nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.
Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci
et nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.

Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset ius et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>
Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset
ius et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>
</div>
<div style="text-align:right;display:block;border:1px solid #000000;">
<div style="display:inline">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius dolorum efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros accommodare sed. Decore scripserit definitiones et pri, at duo purto sale quidam.
<div style="display:inline">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius
dolorum efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros
accommodare sed. Decore scripserit definitiones et pri, at duo purto sale quidam.

Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci et nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.
Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci
et nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.

Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset ius et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>
Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset
ius et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>
</div>
<div style="text-align:center;display:block;border:1px solid #000000;">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius dolorum efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros accommodare sed. Decore scripserit definitiones et pri, at duo purto sale quidam.
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius dolorum
efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros accommodare
sed. Decore scripserit definitiones et pri, at duo purto sale quidam.

Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci et nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.
Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci et
nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.

Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset ius et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset ius
et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>
<div style="text-align:center;display:block;border:1px solid #000000;">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius dolorum
efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros accommodare
sed. Decore scripserit definitiones et pri, at duo purto sale quidam.

Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci et
nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.

Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset ius
et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>
<div style="text-align:center;display:block;border:1px solid #000000;">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius dolorum
efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros accommodare
sed. Decore scripserit definitiones et pri, at duo purto sale quidam.

Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci et
nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.

Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset ius
et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>
<div style="text-align:center;display:block;border:1px solid #000000;">
Lorem ipsum dolor sit amet, ad est tollit percipit definitionem, id facete persius quaerendum qui, persius dolorum
efficiantur et vix. Ad illud malis oratio vix, duo dolor verterem no, eum ad mutat epicurei. At ceteros accommodare
sed. Decore scripserit definitiones et pri, at duo purto sale quidam.

Malis posidonium vix ea. In solum intellegebat quo, has ut dico iusto deleniti. Et vis movet errem. Elit graeci et
nam. An molestie lucilius persecuti quo, ei liber dolorem lucilius vim.

Sint molestiae posidonium mea ei, id usu tamquam postulant, per id ipsum clita euismod. Tale placerat interesset ius
et. Has aeque audiam te. Aperiam habemus ne eum, ei malis putent est.
</div>

Binary file modified examples/wordWrap.pdf
Binary file not shown.
13 changes: 7 additions & 6 deletions lib/Html/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,37 +146,37 @@ public function setGroupOptions(PageGroupBox $root, \DOMDocument $domDocument)
}
}
if ($childDomElement->hasAttribute('data-margin-left')) {
$root->marginLeft = (float)$childDomElement->getAttribute('data-margin-left');
$root->marginLeft = (float) $childDomElement->getAttribute('data-margin-left');
if (!$root->marginLeft) {
$root->marginLeft = 30;
}
}
if ($childDomElement->hasAttribute('data-margin-right')) {
$root->marginRight = (float)$childDomElement->getAttribute('data-margin-right');
$root->marginRight = (float) $childDomElement->getAttribute('data-margin-right');
if (!$root->marginRight) {
$root->marginRight = 30;
}
}
if ($childDomElement->hasAttribute('data-margin-top')) {
$root->marginTop = (float)$childDomElement->getAttribute('data-margin-top');
$root->marginTop = (float) $childDomElement->getAttribute('data-margin-top');
if (!$root->marginTop) {
$root->marginTop = 40;
}
}
if ($childDomElement->hasAttribute('data-margin-bottom')) {
$root->marginBottom = (float)$childDomElement->getAttribute('data-margin-bottom');
$root->marginBottom = (float) $childDomElement->getAttribute('data-margin-bottom');
if (!$root->marginBottom) {
$root->marginBottom = 40;
}
}
if ($childDomElement->hasAttribute('data-header-top')) {
$root->headerTop = (float)$childDomElement->getAttribute('data-header-top');
$root->headerTop = (float) $childDomElement->getAttribute('data-header-top');
if (!$root->headerTop) {
$root->headerTop = 10;
}
}
if ($childDomElement->hasAttribute('data-footer-bottom')) {
$root->footerBottom = (float)$childDomElement->getAttribute('data-footer-bottom');
$root->footerBottom = (float) $childDomElement->getAttribute('data-footer-bottom');
if (!$root->footerBottom) {
$root->footerBottom = 10;
}
Expand Down Expand Up @@ -221,6 +221,7 @@ public function parse()

$pageGroup->buildTree();
$pageGroup->fixTables();
$pageGroup->getStyle()->fixDomTree(false);
$pageGroup->layout();
$page->setBox($pageGroup);

Expand Down
Loading

0 comments on commit 790d8c6

Please sign in to comment.