Skip to content

Commit

Permalink
small view fix
Browse files Browse the repository at this point in the history
  • Loading branch information
razawa committed Jun 6, 2024
1 parent 9bdeb72 commit 8fd4172
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions shared_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -1014,20 +1014,22 @@ public function definition() {
// If the text has HTML <img> - it can broke view template. Try to clean it
/* try {*/
$pdf_text = mb_convert_encoding($pdf_text, 'HTML-ENTITIES', 'UTF-8');
$dom = new DOMDocument;
$dom->loadHTML($pdf_text, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$xpath = new DOMXPath($dom);
$nodes = $xpath->query('//img');
/** @var DOMElement $node */
foreach ($nodes as $node) {
$node->removeAttribute('width');
$node->removeAttribute('height');
// $node->setAttribute('width', '200');
$style = $node->getAttribute('style');
$style .= ';width: 100%;';
$style = $node->setAttribute('style', $style);
if ($pdf_text) {
$dom = new DOMDocument;
$dom->loadHTML($pdf_text, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$xpath = new DOMXPath($dom);
$nodes = $xpath->query('//img');
/** @var DOMElement $node */
foreach ($nodes as $node) {
$node->removeAttribute('width');
$node->removeAttribute('height');
// $node->setAttribute('width', '200');
$style = $node->getAttribute('style');
$style .= ';width: 100%;';
$style = $node->setAttribute('style', $style);
}
$pdf_text = $dom->saveHTML();
}
$pdf_text = $dom->saveHTML();
/*} finally {
// just wrapper
}*/
Expand Down

0 comments on commit 8fd4172

Please sign in to comment.