tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.18k stars 1.51k forks source link

pdf report blank in iphone safari browser #606

Open taha7672 opened 1 year ago

taha7672 commented 1 year ago

code to report generate; $title = 'Sale Comparison'; $content = view( 'admin.reports.sale_comparison', compact( 'title', 'store_id', 'compare', 'compareTo', 'sale_results', ) )->render();

    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    $pdf::SetFont('Times', '', 11, '', false);
    $pdf::SetTitle($title);
    $pdf::setPrintHeader(false);
    $pdf::setFooterCallback(function ($pdf) {
        // Position at 15 mm from bottom
        $pdf->SetY(-15);
        // Set font
        $pdf->SetFont('helvetica', 'I', 8);
        // Page number
        $pdf->Cell(0, 10, 'Page ' . $pdf->getAliasNumPage() . '/' . $pdf->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    });
    $pdf::AddPage('P', "A4");
    $pdf::writeHTML($content, true, false, true, false, '');
    deleteAllStoragePDFs();
    $pdf::Output(storage_path('app/public/pdf/' . $title . '.pdf'), 'F');

    return $path = 'storage/app/public/pdf/' . $title . '.pdf';
}

view .blade::

logo
{{ getConstant('SITE') }}
{{ getConstant('EMAIL') }}
Address: {{ getConstant('ADDRESS') }}
PTCL-1:     {{ getConstant('PTCL-1') }}
PTCL-2:     {{ getConstant('PTCL-2') }}
Contact-1: {{ getConstant('Contact-1') }}
Contact-2: {{ getConstant('Contact-2') }}
Report: {{ $title }}
@php use Carbon\Carbon; @endphp @foreach ($sale_results as $month => $totals) @endforeach
Month {{ $compare }} {{ $compareTo }} Difference
{{ \Carbon\Carbon::createFromDate(null, $month)->format('F') }} {{ $totals[$compare] }} {{ $totals[$compareTo] }} {{ $totals[$compare] - $totals[$compareTo] }}