bir nedenden ötürü, DEAD işlevini çağıran sayfadaki kod dosyaya dökülür. Bu başlık önce yerleştirildi. şimdi anlıyorum: referans harici bir sayfa değildi, içe aktarma ve harici sayfadım. neden tıklamadığını bilmiyorum.
anyway. as soon as i got rid of the page's extra stuff, it worked just fine. in retrospect, what dompdf needed to state was quite simply that NO HTML of ANY kind (echo, print, &c.) can be on the page that calls the function. at least that what it appears to require at this level of my knowledge.
Benim gibi, 'her şey ama cevap' bir yanlış anlama içinde olanlar, işini yapan çıplak kemik kodu:
buildPDF.php:
<?php
session_start();
$_SESSION['someTitle'] = "BIG FAT TITLE";
$_SESSION['someName'] = "HandomeLu";
$theTemplate = 'template.php';
function renderToPDF($templateFile)
{
require_once("_dox/dompdf/dompdf_config.inc.php");
ob_start();
include $templateFile;
$contents = ob_get_clean();
if ($contents !== false)
{
$dompdf = new DOMPDF();
$dompdf->load_html($contents);
$dompdf->render();
$dompdf->stream("kapow_ItWorks.pdf");
}
}
renderToPDF($theTemplate);
?>
and this is the template.php:
<!DOCTYPE HTML>
<html>
<meta>
<head>
<meta charset="utf-8">
<link href="thisPage.css" type="text/css" rel="stylesheet">
</head>
<body>
<?php echo $_SESSION['someTitle'] ?>
wouldn't it be nice, <?php echo $_SESSION['someName'] ?>
</body>
</html>
Ayrıca harici CSS dosyasının sadece iyi okunduğunu unutmayın. Böylece yapı ve stili ayrı tutabilirsiniz. Ayrıca, $ _SESSION değişkenleri herhangi bir yere ayarlanabiliyor, elbette ki, test etmeyi kolaylaştırmak için onları buraya ayarladım.
Umarım bu BÜYÜK sınıfı ile başlayanlar için yararlıdır. PDF dosyalarını kranklamak ve koşturmak için arıyorsanız, bu kadar çok popo tekme, üzerinde bir tetikleyici ve bir tutuş olması gerekir. :)
yorum yapan herkese teşekkürler. Olmam gerektiği yerde beni aldın. :)
Bu site ROCKS.
WR!