Print a document

0

You see, I have the following function to create a document in Word format:

public function imprimir(Articulo $articulo){
    $deciso='descargas/'.$articulo->titulo.'.docx';
    if(!file_exists($deciso)){
        $phpWord=new \PhpOffice\PhpWord\PhpWord();
        $phpWord->getSettings()->setThemeFontLang(new Language(Language::ES_ES));
        $section=$phpWord->addSection();

        $text=$section->addText($articulo->titulo, array('name'=>'Arial','size' => 15,'bold' => true));
        $section->addImage($articulo->foto->ruta(), array('width'=>400, 'height'=>300, 'align'=>'center'));
        $general=array('bold'=>true);

        $text=$section->addText($articulo->texto,$general);
        $text=$section->addText("Articulo publicado por ".$articulo->user->nombre()." en el Aullido Vespertino el ".$articulo->created_at->format('d/m/Y'));

        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
        $objWriter->save($deciso);
    }
    return response()->download(public_path($deciso));
}

Thanks to this I can download files in Word format, but I would like better if the document is printed. That is, if the user has a printer, I want to give him the option to print this document.

How do I achieve that in Laravel? I've searched everywhere, but I have not found anything.

    
asked by Miguel Alparez 23.10.2018 в 17:01
source

0 answers