dimanche 29 octobre 2017

TCPDF save file then redirect

I'm using laravel 5.4 and elibyy/tcpdf-laravel to generated view to PDF. Now I'm trying to save the file then redirect to another page.

I've tried like this, but it became just save and download the file. Not redirect me to the page I wanted.

$view = View::make('view', compact('anything'));
$html = $view->render();

$pdf = new TCPDF();
$pdf::setFooterCallback(function($pdfs) {
    $pdfs->SetY(-15);
    $pdfs->SetFont('helvetica', 'I', 8);
    $pdfs->Cell(0, 10, 'Page '.$pdfs->getAliasNumPage().' of '.$pdfs->getAliasNbPages(), 0, false, 'R', 0, '', 0, false, 'T', 'M');
});
$pdf::SetTitle('Title');
$pdf::AddPage();
$pdf::writeHTML($html, true, false, true, false, '');
$pdf::Output(public_path('path/to/location/file.pdf'), 'FD');

return redirect()->route('somewhere')->with('success', 'Success');



via Chebli Mohamed

1 commentaire:

  1. ExpressTech Software Solutions is Leading Laravel Development Company India and USA offers Services like Laravel Development Services, Extension Development, Custom Module . +91-9806724185 or Contact@expresstechsoftwares.com

    RépondreSupprimer