In coeigniter 3
I have following method to create html content for dompdf
based on data fetched from a SQL table which already created by ckeditor
on my web portal:
public function generatePageHtml($report_name, $title1, $title2 = null, $title3 = null, $content, $image_path, $cover1_image_path = null, $cover2_image_path = null, $page_number = null) {
$cover_base64 = $this->getCoverImageBase64($title2, $cover1_image_path, $cover2_image_path, $image_path);
$html = '';
$html .= '<html><body>';
if ($cover_base64) {
$html .= '<img src="' . $cover_base64 . '" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; object-fit: cover; margin: 0; padding: 0; opacity: 0.3;">';
}
// Load logo image
$logo_html = $this->generateLogoHtml();
if ($title2 !== 'Cover 1' && $title2 !== 'Back Cover') {
if ($logo_html) {
$html .= $logo_html;
}
}
$html .= '<div style="position: relative; z-index: 2; padding: 20px;">';
if ($title2 !== 'Cover 1' && $title2 !== 'Back Cover') {
$html .= $this->generateTitleHtml($title1, $title2);
}
$html .= '<div style="margin: 10px 25px 4px 5px;">';
$html .= '<div>' . $content . '</div>';
$html .= '</div>';
$html .= '</div>';
if ($title2 !== 'Cover 1' && $title2 !== 'Back Cover') {
$html .= '<div style="position: absolute; bottom: 20px; left: 20px; font-size: 12px; font-weight: bold; font-style: italic; color: black;"> '
. $report_name .' - '. $title1 .' - '. $title2 . '</div>';
}
$html .= '</body></html>';
return $html;
}
In fact, this code is used in a for loop to create html
content for dompdf
from various SQL table columns aimed to create a compilate report. Here I have 2 main troubles:
1-Sometime the content of each column could exceed one a4 page (landscape); but in the generated pdf, the page margins are not considered for these exceeded pages! So the content in them has no margin while I need to consider same styling overall for the report pdf.
2-Secondly, some HTML content could use the Bootstrap library. e.g. icons or other paragraph styling. So the final generated pdf should be faithful to user content styling while I include this library in the head of the html, but that does not make sense. e.g. the coeditor content has 2 column-styled paragraph. In the generated pdf they are placed as 1 column paragraph.
in attach is an image of what i mean!
in brief bootstrap does not acted as expected in pdf generation even when i include any version or any online or on server source. Do you have any suggestions to deal with these concepts?