PHP code example of zsgsdesign / laravel-pdf-latex
1. Go to this page and download the library: Download zsgsdesign/laravel-pdf-latex library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zsgsdesign / laravel-pdf-latex example snippets
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use ZsgsDesign\PDFConverter\Latex;
class TestController extends Controller
{
/**
* Download PDF generated from latex
*
* @return Illuminate\Http\Response
*/
public function download(){
return (new Latex)->dryRun();
}
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use ZsgsDesign\PDFConverter\Latex;
class TestController extends Controller
{
/**
* Download PDF generated from LaTex
*
* @return Illuminate\Http\Response
*/
public function download(){
return (new Latex('latex.tex'))->with([
'name' => 'John Doe',
'dob' => '01/01/1994',
'addresses' => [
'20 Pumpkin Hill Drive Satellite Beach, FL 32937',
'7408 South San Juan Ave. Beaver Falls, PA 15010'
]
])->download('test.pdf');
}
namespace App\Listeners;
use ZsgsDesign\PDFConverter\LatexPdfWasGenerated;
class LatexPdfWasGeneratedConfirmation
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param LatexPdfWasGenerated $event
* @return void
*/
public function handle(LatexPdfWasGenerated $event)
{
// Path of pdf in case in was saved
// OR
// Downloaded name of pdf file in case it was downloaded in response directly
$pdf = $event->pdf;
// download OR savepdf
$action = $event->action;
// metadata $user in this example
$user = $event->metadata;
// Perform desired actions
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.