I am using MPDF which I have installed using composer. I have some content stored in a MySQL database which includes the HTML tags as well as the text. I would like the user to be able to create and edit their own letters.
When I go to print the pdf I get a PDF page with the HTML tags displayed on the page. The strange thing is; if I take that output and copy it and past it into the WriteHTML() function in the PHP page the page will render with the proper text and formatting. It doesn't seem to be an issue with the HTML markup, but how Mpdf is rendering the HTML.
Here is the $headder output before it is sent to $WriteHTML:
<h1 style="text-align: center;">Baddeck Academy Scholarships</h1> <h6
style="text-align: center; line-height: 1;"><span style="color:
#e67e23;">320 Shore Rd.</span></h6> <h6 style="text-align: center;
line-height: 1;"><span style="color: #e67e23;">Baddeck, NS</span></h6>
<h6 style="text-align: center; line-height: 1;"><span style="color:
#e67e23;">B0E 1B0</span></h6>
Here is the exported page content as well as the code that I am using.
Here is the Mpdf php page:
<?php
include('connect.php');
$id = (filter_var($_GET['id'], FILTER_SANITIZE_STRING));
$sql = "SELECT * FROM `money_letters_contents` WHERE `id` = '$id' LIMIT 0,1000";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
$headder = ($row['headder']);
$body = ($row['body']);
$footer = ($row['footer']);
}
} else {
}
$html = $headder;
//==============================================================
//==============================================================
//==============================================================
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new mPDF();
$mpdf->WriteHTML("$headder");
$mpdf->WriteHTML("$body");
$mpdf->Output();
exit;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…