/dev/null", $status ); } } else { // cp -f pdf system( "cp -f $pdftmp $pdfcache &>/dev/null", $status ); } // pdf output by browser header self::browser_header( $pdfcache ); } // throw error throw new Exception( "PHP Warning: $pdftmp is no exists." ); } // update html to htmlcache static function update_html_output( $basename, $doc, $htmltmp, $htmlcache ) { // create head via doc $head = self::createHead( $doc ); // create html doc $html = ''; $html .= ''. $head['Title'] .''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= file_get_contents( $htmltmp ); $html .= '
'; // add download pdf icon by Chrome: Developer Tools $html .= '
'; // datasheet quote for no bot if ( !self::bot_detection() ) { // @product: insert HTMLForm.php via /mnt/iiic/product include_once( '/mnt/iiic/product/includes/htmlform/HTMLForm.php' ); $html .= get_contact_modal(); //IMP: zoom body $html .= ''; // product: plugin.min.js $html .= ''; $html .= ''; } // end html $html .= ''; file_put_contents( $htmlcache, $html ); // FIXME: PHP Warning: unlink No such file @unlink( $htmltmp ); // file output by html header self::html_header( $htmlcache ); } // pdfmd5 = (32)0: create_pdf_output static function create_pdf_output( $doc ) { // https://mpdf.github.io/fonts-languages/choosing-a-configuration-v7-x.html // to use core fonts only, use 'c' for the mode configuration key: $mpdf = new \Mpdf\Mpdf( [ 'mode' => 'c', 'default_font_size' => 15, 'tempDir' => '/dev/shm' ] ); // 4th | %PDF1.5 | 6.x $mpdf->pdf_version = '1.5'; // doc.details $model = $doc['model']; $manufacturer = $doc['manufacturer']; $description = $doc['description']; $datasheet_link = 'https://www.datasheet.live/'. rawurlencode( $model ) .'-datasheet.html'; $product_link = 'https://www.product.network/'. rawurlencode( $model ) .'-product.html'; // document metadata $mpdf->SetTitle( $_SERVER['HTTP_HOST'] .' '. $model ); $mpdf->SetAuthor( $_SERVER['HTTP_HOST'] ); $mpdf->SetCreator( $_SERVER['HTTP_HOST'] ); $mpdf->SetSubject( $_SERVER['HTTP_HOST'] ); $mpdf->SetKeywords( $_SERVER['HTTP_HOST'] .' '. $description ); // define an html headers/footers $mpdf->defaultheaderfontsize = 12; $mpdf->defaultfooterfontsize = 12; $mpdf->SetHeader( '| '. $model .' |' ); $mpdf->SetFooter( '© {DATE Y} | https://'. strtolower( $_SERVER['HTTP_HOST'] .' |' ) ); // https://www.php.net/manual/en/function.file-get-contents.php // https://www.jsdelivr.com/package/npm/bootstrap $stylesheet = file_get_contents( __DIR__ . '/images/mpdf.css' ); $mpdf->WriteHTML( $stylesheet, \Mpdf\HTMLParserMode::HEADER_CSS ); // html content body // https://mpdf.github.io/css-stylesheets/supported-css.html#common-text-styles $html = <<

$model

$manufacturer

$description

EOF; $mpdf->WriteHTML( $html, \Mpdf\HTMLParserMode::HTML_BODY ); // Adobe Portable Document Format (PDF) header( 'Content-Type: application/pdf' ); // output a pdf file directly to the browser $mpdf->Output(); exit; } } // index.php pdf output $datasheet = new DataSheet(); $datasheet->run();