Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function imprimir(Articulo $articulo){
- $deciso='descargas/'.$articulo->titulo.'.docx';
- if(!file_exists($deciso)){
- $phpWord=new PhpOfficePhpWordPhpWord();
- $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 = PhpOfficePhpWordIOFactory::createWriter($phpWord, 'Word2007');
- $objWriter->save($deciso);
- }
- return response()->download(public_path($deciso));
- }
Add Comment
Please, Sign In to add comment