Warnung bei Erzeugung von pdf mit Dompdf

Status
Nicht offen für weitere Antworten.
Moin,

das hatte ich befürchtet ... :-]

Und warum postet Du dann nicht den konkreten Pfad, so wie er im Dateisystem vorkommt ??? :(
Isses denn so schwer ?? ;)

Gruß Klaus
 
Moin,

das hatte ich befürchtet ... :-]

Und warum postet Du dann nicht den konkreten Pfad, so wie er im Dateisystem vorkommt ??? :(
Isses denn so schwer ?? ;)

Gruß Klaus
also alle meine Bilder befinden sie sich in dem folgenden Pfad C:\xampp\htdocs\kan\images
von dort werden die Bilder geholt und hier
PHP:
$htmlString .= '<div style="position: relative;">
                              <img style=" z-index: 1; left: 40px; top: 10px; width: 190px; height: 170px;" src="images/' . $path . '" border="0"/></div></td>';
plaziert ($path), und dann in pdf umgewandelt.
 
...
Kannst du uns den Code zeigen, wie du Dompdf aufrufst?
Oder sogar den ganzen Code in der Datei?

Was steht in $path?
 
...
Kannst du uns den Code zeigen, wie du Dompdf aufrufst?
Oder sogar den ganzen Code in der Datei?

Was steht in $path?
so fange ich mein Code an :
PHP:
$selection = $dbConnect->prepare('SELECT * FROM drucker WHERE sessionID = :sessionID');

$selection->bindValue(':sessionID', $sessionID);
$selection->execute();


$prints = $selection->fetchAll(PDO::FETCH_ASSOC);
$products = array();

foreach ($prints as $print) {

    if ($print['type'] === 'product') {
        $productsData = $dbConnect->prepare('SELECT * FROM product WHERE id = :id');
        $productsData->bindValue(':id', $print['prod_id']);
    } else {
        $productsData = $dbConnect->prepare('SELECT v.*, p.path FROM variants v LEFT JOIN product p ON p.id = v.img_id WHERE p.id = :id AND v.id = :v_id');
        $productsData->bindValue(':id', $print['img_id']);
        $productsData->bindValue(':v_id', $print['prod_id']);
    }

    $productsData->execute();
    $products[] = $productsData->fetch(PDO::FETCH_ASSOC);
}

$length = count($products);
$htmlString = '';

$path = isset($products[$p]["path"]) ? $products[$p]["path"] : '';
                $htmlString .= '<div style="position: relative;">
                               <img style=" z-index: 1; left: 40px; top: 10px; width: 190px; height: 170px;" src="images/' . $path . '" border="0"/></div></td>';

wie ich Dompdf aufrufe
PHP:
<?php
$sessionID = $_POST['sessionID'];
/** @var array $data */
$data = array();
require_once __DIR__ . '/html_to_pdf/dompdf/autoload.inc.php';
use Dompdf\Dompdf;

$file_path = __DIR__ . '/pdfs/pagepdf_'.$sessionID.'.html';
$file_path_pdf = __DIR__ . '/pdfs/pagepdf_'.$sessionID.'.pdf';
$pdf_download = str_replace('print.php', '', $_SERVER['REQUEST_URI']). 'pdfs/pagepdf_'.$sessionID.'.pdf';

if ($html = file_get_contents($file_path)) {

    $dompdf = new Dompdf('P', 'A4', 'de', true, 'UTF-8');
    $dompdf->loadHtml($html,'UTF-8');

    $dompdf->setPaper('A4', 'portrait');
    $dompdf->render();

    $output = $dompdf->output();
    file_put_contents($file_path_pdf, $output);

    $data['success'] = true;
    $data['filePath'] = $pdf_download;

} else {
    $data['success'] = false;
}

// return all our data to an AJAX call
echo json_encode($data);

wie schon gesagt, alles kalppt gut, ich bekomme meine Pdf-Datei mit allen Daten, leider die Warnung macht alles kaputt
 
Zuletzt bearbeitet:
PHP:
$path = isset($products[$p]["path"]) ? $products[$p]["path"] : '';
Die Variable $p gibts nicht.
$path ist deswegen leer.
...
Und getimagesize will eben kein Verzeichnis.
 
es hat mir Zeit gekostet bis ich endlich eine Lösung gefunden habe

PHP:
src="./images/' . $path . '"

dann keine Warnung mehr

vielen Dank für eure Hilfe
 
PHP:
$path = isset($products[$p]["path"]) ? $products[$p]["path"] : '';
Die Variable $p gibts nicht.
$path ist deswegen leer.
...
Und getimagesize will eben kein Verzeichnis.
Hi sheel,

ich bin auf die Idee gekommen dass du völlig recht hast ist die variable $p wirklich leer,
ich frage mich jetzt wie werde ich es lösen damit ich endlich mal durch wird.
 
hallo,
ich habe mir ein Teil der Kopie von der erstellte html besonders an der stelle wo ich glaube gibt es problem so sieht es aus.
bitte wenn sie Vorschläge haben, einfach vorschlagen.
sie können genauso wie ich sehen, dass die Pfade stimmen.


HTML:
<img style=" z-index: 1; left: 40px; top: 10px; width: 190px; height: 170px;" src="images/Kant8.png" border="0"/></div></td>
<img style=" z-index: 1; left: 51px; top: 22px; width: 190px; height: 170px;" src="images/Kant1.png"  border="0" /></div></td>
<img style=" z-index: 1; left: 40px; top: 10px; width: 190px; height: 170px;" src="images/Kant4.png" border="0"/></div></td>
<img style=" z-index: 1; left: 51px; top: 22px; width: 190px; height: 170px;" src="images/Kant4.png"  border="0" /></div></td>
<img style=" z-index: 1; left: 40px; top: 10px; width: 190px; height: 170px;" src="images/Kant1.png" border="0"/></div></td>
<img style=" z-index: 1; left: 51px; top: 22px; width: 190px; height: 170px;" src="images/0wa.jpg"  border="0" /></div></td>
 
Status
Nicht offen für weitere Antworten.
Zurück