hi
dompdf doesn’t appear to work when trying to stream a pdf on the fly. the pdf file content is not correct.
trying to create a pdf to display/download (calling from dashboard for testing), code is in userfn.php
function _getSampleReport($campaignid) {
$dompdf = new \Dompdf\Dompdf();
$options = $dompdf->getOptions();
$options->set("isRemoteEnabled", true);
$options->set('defaultFont', 'Courier');
$dompdf->setOptions($options);
$dompdf->setPaper('A4', 'portrait');
$ht = "hello world";
$dompdf->loadHtml($ht);
$dompdf->render();
$dompdf->stream("mypdf.pdf", array("Attachment" => true));
}
creates a document file with this content:
<!DOCTYPE html>
<html lang="en-US" data-bs-theme="light">
<head>
<title>DocuManage</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/css/select2.min.css?v=25.11.1">
<link rel="stylesheet" href="/css/select2-bootstrap5.min.css?v=25.11.1">
<link rel="stylesheet" href="/plugins/fontawesome-free/css/all.min.css?v=25.11.1">
<link rel="stylesheet" href="/adminlte3/css/adminlte.css?v=25.11.1">
<link rel="stylesheet" href="/css/docuManage.css?v=25.11.1">
<script data-pace-options='{"ajax":{"trackMethods":["GET","POST"],"ignoreURLs":["\/session?"]},"eventLag":false}' src="/js/pace.js?v=25.11.1"></script><!-- Single quotes for data-pace-options -->
<script src="/js/ewcore.js?v=25.11.1"></script>
<script>
var $rowindex$ = null;
Object.assign(ew, {"DEBUG":false,"SESSION_TIMEOUT_COUNTDOWN":120,"SESSION_KEEP_ALIVE_INTERVAL":0,"API_FILE_TOKEN_NAME":"filetoken","API_URL":"api\/","API_ACTION_NAME":"action","API_OBJECT_NAME":"table","API_LIST_ACTION":"list","API_VIEW_ACTION":"view","API_ADD_ACTION":"add","API_EDIT_ACTION":"edit","API_DELETE_ACTION":"delete","A
anyone able to create a pdf using the ->stream method?
saving the content to a file first for example using the output method:
$output = $dompdf->output();
file_put_contents(“mypdf.pdf”, $output);
renders the pdf correctly…
thanks,
JS