WKHTMLtoPDF Header File Contents Not Displayed in PDF File

I am trying to hide the header page number on the first page using this example I found here . This only works if I use it with footer-html and donโ€™t show / hide anything if I use it with header-html. I initially tried to increase this solution , which also worked using footer-html, but since I couldnโ€™t get it working in the header, I continued to search. I tried this with and without 'header-center' => '[[page]]' if using this in header-html conflicts. Has anyone managed to get this to work in the headlines recently? I use the PHPWKHTMLtoPDF version of the wrapper version 1.2.6-dev if this helps with the updated version of WKHTMLtoPDF, since the newest version of PHPWKHTMLtoPDF uses namespaces, and we use CodeIgniter 2.x-dev, which does not support them (or I donโ€™t remember playing well) .

// Create document PDF $pdf = new $this->wkhtmltopdf; // Locate WkHtmlToPdf executable for Windows if( $pdf->getIsWindows() ) { $pdf->setOptions( array( 'binPath' => 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe', 'no-outline', 'encoding' => 'UTF-8', 'margin-top' => 30, 'margin-right' => 20, 'margin-bottom' => 30, 'margin-left' => 20, // Default page options 'disable-smart-shrinking', 'user-style-sheet' => 'pdf.css', 'header-html' => dirname(__FILE__) . '\..\views\wkhtmltopdf\header.html' ) ); } // Generate document fields $docInputs = $this->generate_inputs( $inputs, json_decode( $this->load->file( APPPATH . '/mapping/' . $document['mapping'], TRUE ), TRUE ) ); // Merge document fields into HTML exported Word files $docHTML = $this->parser->parse( 'docs/' . $document['html'], $docInputs, TRUE ); // Add HTML as page, along with option for page header $pdf->addPage( $docHTML, array( 'header-center' => '[[page]]', 'header-spacing' => '10', 'header-font-name' => 'Times New Roman' ) ); 
+6
source share
2 answers

You need to add <!DOCTYPE html> to the header file, WKHTMLtoPDF issue # 46 for version 0.12

+23
source

I am posting this answer because it happened to me, and that could also be the reason.

I also noticed if you set the css header for this. It does not display the title.

 html{ width: 100%; height: 100%; } 
0
source

Source: https://habr.com/ru/post/980721/


All Articles