Ale ja zmieniłem i nie mam już tego ob_start
Tak wygląda skrypt generowania faktur
function mpdf_output_wp_zmarli($content ='',$outputToBrowser = true, $pdfName = '', $templatePath = '' ){
// Require composer autoload
require __DIR__ . '/generator/vendor/autoload.php';
$pdf_ofilename = get_option
('zmarli_name_pdf').'_'.date('d-m-Y H:i', time()).'.pdf'; if ( ! empty( $pdfName ) ) { $pdf_filename = $pdfName . '.pdf';
} else {
$pdf_filename = $pdf_ofilename;
}
if (get_option('pdf_format')) {
$pdf_format =get_option('pdf_format');
}
if (get_option('pdf_margin_left') !== 0 && get_option('pdf_margin_left') == '' ) {
$pdf_margin_left = get_option('pdf_margin_left');
}
if (get_option('pdf_margin_right') !== 0 && get_option('pdf_margin_right') == '' ) {
$pdf_margin_right = get_option('pdf_margin_right');
}
if (get_option('pdf_margin_top') !== 0 && get_option('pdf_margin_top') == '' ) {
$pdf_margin_top = get_option('pdf_margin_top');
}
if (get_option('pdf_margin_bottom') !== 0 && get_option('') == 'pdf_margin_bottom' ) {
$pdf_margin_bottom = get_option('pdf_margin_bottom');
}
if (get_option('pdf_margin_header') !== 0 && get_option('pdf_margin_header') == '' ) {
$pdf_margin_header = get_option('pdf_margin_header');
}
if (get_option('pdf_margin_footer') !== 0 && get_option('pdf_margin_footer') == '' ) {
$pdf_margin_footer = get_option('pdf_margin_footer');
}
if (empty(get_option
('pdf_html_header') )) { $pdf_html_header = false;
}
if (empty(get_option
('pdf_html_footer'))) { $pdf_html_footer = false;
}
if (get_option("pdf_orientation")) {
$pdf_orientation = get_option("pdf_orientation");
}
$cp = 'utf-8';
if (get_option('zmarli_code_pdf') != '' ) {
$cp = get_option('zmarli_code_pdf');
}
$defaultConfig = (new Mpdf\Config\ConfigVariables())->getDefaults();
$fontDirs = $defaultConfig['fontDir'];
$defaultFontConfig = (new Mpdf\Config\FontVariables())->getDefaults();
$fontData = $defaultFontConfig['fontdata'];
// Create an instance of the class:
$mpdf = new \Mpdf\Mpdf([
'tempDir' => __DIR__ . '/generator/log',
'mode' =>$cp,
'format' => $pdf_format,
'orientation' => $pdf_orientation,
'margin_left' => $pdf_margin_left,
'margin_right' => $pdf_margin_right,
'margin_top' => $pdf_margin_top,
'margin_bottom' => $pdf_margin_bottom,
'margin_header' => $pdf_margin_header,
'margin_footer' => $pdf_margin_footer,
__DIR__ . '/generator/vendor/mpdf/mpdf/ttfonts',
]),
'fontdata' => $fontData + [
'dejavusans' => [
'R' => 'DejaVuSans.ttf',
]
]
]);
$mpdf->charset_in = $cp;
$mpdf->title2annots = false;
//$mpdf->annotMargin = 12;
$mpdf->onlyCoreFonts = false; // false is default
$mpdf->SetBasePath( $templatePath );
//Set PDF Template if it's set
global $pdf_template_pdfpage_page;
if ( isset($pdf_template_pdfdoc) && $pdf_template_pdfdoc != '' ) { $mpdf->SetDocTemplate($templatePath.$pdf_template_pdfdoc, true );
} else if (isset($pdf_template_pdfpage) && $pdf_template_pdfpage != '' && isset($pdf_template_pdfpage_page) && is_numeric($pdf_template_pdfpage_page)) { $pagecount = $mpdf->SetSourceFile($templatePath.$pdf_template_pdfpage );
if ($pdf_template_pdfpage_page < 1 ) {
$pdf_template_pdfpage_page = 1;
} else if ($pdf_template_pdfpage_page > $pagecount ) {
$pdf_template_pdfpage_page = $pagecount;
}
$tplId = $mpdf->ImportPage($pdf_template_pdfpage_page);
$mpdf->UseTemplate($tplId);
}
$mpdf->SetAuthor(get_option('Parafia'));
$mpdf->SetCreator( 'wp-zmarli' );
//The Header and Footer
if (get_option('pdf_html_header') == True) {
$mpdf->SetHTMLHeader( $pdf_header );
} else {
$mpdf->setHeader( $pdf_header );
}
if (get_option('pdf_html_footer') == True) {
$mpdf->SetHTMLFooter( $pdf_footer );
} else {
$mpdf->setFooter( $pdf_footer );
}
/**
* Allow to override any settings before writing the output
*/
$mpdf = apply_filters( 'wp-zmarli_adjust_settings', $mpdf );
if (get_option
('zmarli_theme_pdf') != '' && file_exists($templatePath.get_option
('zmarli_theme_pdf').'.css' ) ) { //Read the StyleCSS
$mpdf->WriteHTML( $tmpCSS, \Mpdf\HTMLParserMode::HEADER_CSS );
}
$mpdf->WriteHTML($content);
/**
* Allow to process the pdf by an 3th party plugin
*/
do_action( 'mpdf_output_wp_zmarli', $mpdf, $pdf_filename );
if ( get_option('zmarli_caching_pdf' ) == true ) {
file_put_contents
( mpdf_getcachedir_wp_zmarli
() . get_option
( 'zmarli_theme_pdf' ) . '_' . $pdf_ofilename . '.cache', date('d-m-Y', time()) ); $mpdf->Output( mpdf_getcachedir_wp_zmarli().get_option( 'zmarli_theme_pdf' ).'_'.$pdf_ofilename, 'F' );
if ( $outputToBrowser == true ) {
$mpdf->Output($pdf_filename, 'D' );
}
} else {
if ( $outputToBrowser == true ) {
$mpdf->Output($pdf_filename, 'I' );
}
}
}
Tą function zapisuje wyniki
Tak wygląda skrypt wyjściowy to co ma być wygenerowane dla użytkownika i administratora
<?php
$current_user = wp_get_current_user();
$generuj=$wpdb->get_row("SELECT zm.*, w.*, u.* FROM ".$wpdb->prefix."zamowienia_mszy zm
LEFT JOIN ".$wpdb->prefix."wyszukiwarka w ON zm.zamowienia_mszy_id_zmarlej = w.Id
LEFT JOIN ".$wpdb->prefix."users u ON zm.zamowienia_mszu_user_id = u.ID
WHERE zamowienia_mszy_id=".$_GET['zamowienia_mszy_id']." OR zamowienia_mszu_user_id=".$current_user->ID."");
$dane_zmarłego = $generuj->imie." ".$generuj->nazwisko;
$html ='<table border="0" valign="middle">
<tr align="center" style="display:table-cell;vertical-align:middle;">
<td height="20px" ></td><td height="20px"></td><td height="20px">'.get_option
('miejscowosc').' '.date("d-m-Y", time()) .'</td> </tr>
<tr>
<td align="center"></td><td align="center" ></td><td align="center">'.__('Miejscowość, data','zamow_msze').'</td>
</tr>
</table>
<div class="clear"></div>
<table border="0">
<tr align="center" style="display:table-cell;vertical-align:middle;">
<td height="20px" >Miłosierdzia Bożego w Puławach'.get_option('parafia').'</td><td height="20px" border-color="#E0E0E0" ></td><td bordercolor="#E0E0E0" height="20px">'.$generuj->zamowienia_mszy_zamawiajacy.'</td>
</tr>
<tr>
<td align="center">'.__('Nazwa Parafii ','zamow_msze').'</td><td align="center"></td><td align="center">'.__('Imię i nazwisko zamawiąjącego','zamow_msze').'</td>
</tr>
</table>
<h1 style="text-align:center;">'.__('POTWIERDZENIE ZAMÓWIENIA','zamow_msze').'</h1>
<table border="0">
<tr style="display:table-cell;vertical-align:middle;">
<td height="20px" >'.sprintf(__
('Szanowna/ny %s,','zamow_msze'), $generuj->zamowienia_mszy_zamawiajacy).'<br /><br /> '.sprintf(__
('Uprzejmie informuję, iż Msza Święta za zmarłą/łego %s,','zamow_msze'), $dane_zmarłego
).''.sprintf(__
('Złozona/ny w sektorze %s,','zamow_msze'), $generuj->sektor).''.sprintf(__
('Rządzie %s,','zamow_msze'), $generuj->rzad).''.sprintf(__
('pole Grobu %s,','zamow_msze'), $generuj->pole_grobu).''.__
('Została zamówiona. <br />','zamow_msze').' '.__('Wszystkie informacje są informacjami, dla zamawiającego Mszę. To potwierdzienie jest potwierdzieniem że msza została zamówiona i można nim się opszeć w kancelarii.<br /><br /> Zapraszamy do kancelarii o opłacenie tej Mszy świętej.','zamow_msze').'<br /><br />
<br /><br /></td>
</tr>
</table>
<table border="0" style="width:626px;float:right;position: relative; left:50px;">
<tr>
<td>'.__('Z poważaniem','zamow_msze').'</td>
</tr>
<tr>
<td align="right">'.__('ks.Proboszcz','zamow_msze').'</td>
</tr>
</table>
<style>
.clear{clear:both}
</style>';
echo mpdf_output_wp_zmarli
($html,get_option
('zmarli_name_pdf'), ZMARLI_PATH
.'theme/' );