Я получаю эту ошибку, когда пытаюсь загрузить изображение - PullRequest
0 голосов
/ 27 мая 2020

Итак, этот сценарий счета, который я использую для изучения кода путем его реинжиниринга, заставил меня застрять на этом этапе.

В основном, когда я нажимаю кнопку загрузки pdf, я получаю следующую ошибку:

Неустранимая ошибка: Неперехваченная ошибка: Класс 'Svg \ Document' не найден в /Applications/XAMPP/xamppfiles/htdocs/pdf-invoice-generator/vendor/dompdf/dompdf/src/Helpers.php: 620 Трассировка стека: # 0 /Applications/XAMPP/xamppfiles/htdocs/pdf-invoice-generator/vendor/dompdf/dompdf/src/FrameReflower/Image.php(125): Dompdf \ Helpers :: dompdf_getimagesize ('/ Applications / X ... ', NULL) # 1 /Applications/XAMPP/xamppfiles/htdocs/pdf-invoice-generator/vendor/dompdf/dompdf/src/FrameReflower/Image.php(48): Dompdf \ FrameReflower \ Image -> get_min_max_width () # 2 /Applications/XAMPP/xamppfiles/htdocs/pdf-invoice-generator/vendor/dompdf/dompdf/src/FrameDecorator/AbstractFrameDecorator.php(895): Dompdf \ FrameRelow \ Image Объект (Dompdf \ FrameDecorator \ Block)) # 3 / Applications / XAMPP / xamppfiles / htdocs / pdf -invoice-generator / vendor / dompdf / dompdf / src / FrameReflower / Block. php (845): Dompdf \ FrameDecorator \ AbstractFrameDecorator-> reflow (Object (Dompdf \ FrameDecorator \ Block)) # 4 / Applications / XAMPP / xamppfiles / htdocs / pdf-invoice-generator / vendor / dompdf / dompdf / src / FrameDeco в /Applications/XAMPP/xamppfiles/htdocs/pdf-invoice-generator/vendor/dompdf/dompdf/src/Helpers.php в строке 620

Это происходит, только когда я бросаю изображение. Когда я делаю это без него, счет отлично печатается в формате PDF.

Вот мой код:

<?php

require_once 'vendor / dompdf / dompdf / autoload.in c. php '; используйте Dompdf \ Dompdf;

$company_name = urldecode($_POST['company_name']);
$company_address_contact = urldecode($_POST['company_address_contact']);
$title = urldecode($_POST['title']);
$number = urldecode($_POST['number']);
$billtolabel = urldecode($_POST['billtolabel']);
$logo_img = urldecode($_POST['logo_img']);
$clientname = urldecode($_POST['clientname']);
$clientinfo = urldecode($_POST['clientinfo']);
$issuedatelabel = urldecode($_POST['issuedatelabel']);
$issuedate = urldecode($_POST['issuedate']);
$netdayslabel = urldecode($_POST['netdayslabel']);
$netdays = urldecode($_POST['netdays']);
$currencylabel = urldecode($_POST['currencylabel']);
$currency = urldecode($_POST['currency']);
$ponumberlabel = urldecode($_POST['ponumberlabel']);
$ponumber = urldecode($_POST['ponumber']);
$itemlabel = urldecode($_POST['itemlabel']);
$quantitylabel = urldecode($_POST['quantitylabel']);
$pricelabel = urldecode($_POST['pricelabel']);
$linetotallabel = urldecode($_POST['linetotallabel']);
$subtotalsum = urldecode($_POST['subtotalsum']);
$taxsum = urldecode($_POST['taxsum']);
$totalsum = urldecode($_POST['totalsum']);
$noteslabel = urldecode($_POST['noteslabel']);
$termsnotesvalue = urldecode($_POST['termsnotesvalue']);
$items = $_POST['items'];
$tax = floatval($_POST['tax']);
$str = "";
$str = "

<html lang=\'en\'>
<head>
<meta charset=\'UTF-8\'>
<title>Sample Invoice</title>
<link rel='stylesheet' href='css/invoicestyle.css' type='text/css'>
</head>
<body>
    <div id='invoice' class='download_invoice'>
        <div id='memo'>
            <div id='company_info'>
            <div id='company_name'>".$company_name."</div>
            <div id='company_address_contact'>".$company_address_contact."</div>
            </div>
            <div class='clear'></div>
        </div>
        <div id='titlenumber'>
            <div>
                <img id='logo_image' src='".$logo_img."' />
            </div>
            <div style='float:center;'>
                <div id='title'>".$title."</div>
                <div id='number'>".$number."</div>
            </div>
        </div>
        <div id='client'>
            <div id='billtolabel'>".$billtolabel."</div>
            <div id='clientname'>".$clientname."</div>
            <div id='clientinfo'>".$clientinfo."</div>
        </div>
        <div id='netterms'>
            <table cellpadding='0' class='download_invoice' cellspacing='0' border='0'>
                <tr><td><div id='issuedatelabel'>".$issuedatelabel."</div></td><td><div id='issuedate'>".$issuedate."</div></td></tr>
                <tr><td><div id='netdayslabel'>".$netdayslabel."</div></td><td><div id='netdays'>".$netdays."</div></td></tr>
                <tr><td><div id='currencylabel'>".$currencylabel."</div></td><td><div id='currency'>".$currency."</div></td></tr>
                <tr><td><div id='ponumberlabel'>".$ponumberlabel."</div></td><td><div id='ponumber'>".$ponumber."</div></td></tr>
            </table>
        </div>
        <div class='clear'></div>
        <div id='items' class='down_invoice'>
            <table id='items_header_table' class='download_invoice' cellpadding='0' cellspacing='0' border='0'>
                <th></th>
                <th>
                    <div id='itemlabel'>".$itemlabel."</div>
                </th>
                <th>
                    <div id='quantitylabel'>".$quantitylabel."</div>
                </th>
                <th>
                    <div id='pricelabel'>".$pricelabel."</div>
                </th>
                <th>
                    <div id='linetotallabel'>".$linetotallabel."</div>
                </th>
            </table>
            <table id='items_table' class='download_invoice' cellpadding='0' cellspacing='0' border='0'>";
            $subtotalsumvalue = 0;
            $taxsumvalue = 0;
            $total = 0;
            for($i=0;$i<count($items);$i++){
                $subtotalsumvalue += $items[$i]['linetotal'];
                $str .= "<tr><td></td><td><div class='itemname'>".urldecode($items[$i]['itemname'])."</div></td><td><div class='quantity'>".urldecode($items[$i]['quantity'])."</div></td><td><div class='price'>".urldecode($items[$i]['price'])."</div></td><td><div class='linetotal'>".$items[$i]['linetotal']."</div></td></tr>";
            }
            $taxsumvalue = $subtotalsumvalue*$tax;
            $totalsumvalue =  $subtotalsumvalue+$taxsumvalue;
            $subtotalsumvalue = number_format($subtotalsumvalue,2);
            $taxsumvalue = number_format($taxsumvalue,2);
            $totalsumvalue = number_format($totalsumvalue,2);
            $str .= "</table>
        </div>
        <div class='clear'></div>
        <div id='sums' class='down_invoice'>
            <table id='sums_table' cellpadding='0' class='download_invoice sums_table' cellspacing='0' border='0'>
                <tr>
                    <td><div id='subtotalsum'>".$subtotalsum."</div></td>
                    <td><div id='subtotalsumvalue'>".$subtotalsumvalue."</div></td>
                </tr>
                <tr>
                    <td><div id='taxsum'>".$taxsum."</div></td>
                    <td><div id='taxsumvalue'>".$taxsumvalue."</div></td>
                </tr>
            </table>
            <table  id='sums_table' cellpadding='0' class='download_invoice sums_table total' cellspacing='0'>
                <tr>  
                    <td><div id='totalsum'>".$totalsum."</div></td>
                    <td><div id='totalsumvalue'>".$totalsumvalue."</div></td>
                </tr>
            </table>
        </div>
        <div class='clear'></div>
        <div class='stickdown down_invoice'>
            <div id='termsnotes'>
                <div id='noteslabel'>".$noteslabel."</div>
                <div id='termsnotesvalue'>".$termsnotesvalue."</div>
            </div>
        </div>
    </div>
</body>
</html>";
$dompdf = new Dompdf();
$dompdf->loadHtml($str);
$dompdf->setPaper('A4');
$dompdf->render();
$dompdf->stream("invoice.pdf");

?>

PS: Я совершенно новичок в кодировании. Мастер на уровне HTML (кто не смеется) и просто идет глубже, чем уровень поверхности php, который я знаю.

Спасибо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...