<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Solmaz Babakan</title>
    <description>The latest articles on DEV Community by Solmaz Babakan (@solmaz_babakan_648eda209c).</description>
    <link>https://dev.to/solmaz_babakan_648eda209c</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2243518%2Fb86989cf-6816-4dec-bdcd-5629c65a89b5.jpg</url>
      <title>DEV Community: Solmaz Babakan</title>
      <link>https://dev.to/solmaz_babakan_648eda209c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/solmaz_babakan_648eda209c"/>
    <language>en</language>
    <item>
      <title>dompdf page numbering and cover image for html content exceeding one print page.</title>
      <dc:creator>Solmaz Babakan</dc:creator>
      <pubDate>Mon, 21 Oct 2024 14:30:57 +0000</pubDate>
      <link>https://dev.to/solmaz_babakan_648eda209c/dompdf-page-numbering-and-cover-image-for-html-content-exceeding-one-print-page-557p</link>
      <guid>https://dev.to/solmaz_babakan_648eda209c/dompdf-page-numbering-and-cover-image-for-html-content-exceeding-one-print-page-557p</guid>
      <description>&lt;p&gt;Hi everyone.&lt;br&gt;
i fetched some html content from phpmyadmin sql table and print them to pdf by dompdf in my codeigniter 3 project.&lt;br&gt;
here, i have some columns (page titles) with some html content which could exceed one print page (A4 landscape).&lt;br&gt;
as well i add page number or background cover for pages, but just the first page in each column content has cover image and just the last page has footers for page number.&lt;br&gt;
here is the function i used to create html content for dompdf:&lt;br&gt;
PHP Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    // Helper function to generate page HTML with title
    public function generatePageHtml($name,$title1, $title2 = null, $title3 = null, $content, $image_path, $page_number=null) {
        $html = '&amp;lt;div style="position: relative; width: 100%; height: 100%; page-break-after: always; margin: 0; padding: 0;"&amp;gt;';
        $html .= '&amp;lt;style&amp;gt;@page { margin: 0; }&amp;lt;/style&amp;gt;';

        if ($image_path &amp;amp;&amp;amp; file_exists($image_path)) {
            $image = file_get_contents($image_path);
            $base64 = 'data:image/jpeg;base64,' . base64_encode($image);
            $html .= '&amp;lt;img src="' . $base64 . '" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; object-fit: cover; margin: 0; padding: 0;"&amp;gt;'; // opacity: 0.7;
        }

        $html .= '&amp;lt;div style="padding: 20px; position: relative; z-index: 1; margin: 0;"&amp;gt;';
        $html .= '&amp;lt;h1 style="text-align: center; text-decoration: underline; margin: 0;"&amp;gt;' . $title1 . '&amp;lt;/h1&amp;gt;';

        if ($title2) {
            $html .= '&amp;lt;h2 style="text-align: center; margin: 0;"&amp;gt;' . $title2 . '&amp;lt;/h2&amp;gt;';
        }
        if ($title3) {
            $html .= '&amp;lt;h3 style="text-align: center; margin: 0;"&amp;gt;' . $title3 . '&amp;lt;/h3&amp;gt;';
        }

        $html .= $content;
        $html .= '&amp;lt;/div&amp;gt;';
        $html .= '&amp;lt;div style="position: absolute; bottom: 20px; left: 20px; font-size: 12px; font-weight: bold;font-style: italic; color: gray;"&amp;gt; '. $name .' - '. $title1. ' - '. $title2. '&amp;lt;/div&amp;gt;';

        if ($page_number !== null) {
            $html .= '&amp;lt;div style="position: absolute; bottom: 20px; right: 10px; font-size: 12px; font-weight: bold; color: gray;border: 1px solid black; padding: 10px; display: inline-block; border-radius: 3px;"&amp;gt; '.$page_number . '&amp;lt;/div&amp;gt;';
        }
        $html .= '&amp;lt;/div&amp;gt;';
        return $html;
    } 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;how should i consider coding so that when a html content exceeds one print page, the next pages of same content as well has cover image and page numbering for all.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
