Files
aso/app/Http/Controllers/GeneratedDocumentController.php
2026-02-04 14:39:20 +07:00

95 lines
3.1 KiB
PHP

<?php
namespace App\Http\Controllers;
use App;
use App\Models\GeneratedDocument;
use Illuminate\Http\Request;
use PDF;
use Response;
class GeneratedDocumentController extends Controller
{
// Display Content from generated_documents to used by pdf generator (wkhtmltopdf)
public function show($id)
{
$document = GeneratedDocument::findOrFail($id);
return $document->html_content.$document->html_content.$document->html_content.$document->html_content.$document->html_content;
}
public function header(Request $request)
{
return '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<pre>'.json_encode($request->toArray()).'
<table>
<tbody>
<tr>
<td style="width: 200px; background-color: #00be67;"> asdkjasnd </td>
<td style="width: 500px; background-color: #0a94e3;" align="center"> asjdkadsn </td>
<td style="width: 200px; background-color: #7b3f25" align="right"> qkjwenkqwjenkqwjen </td>
</tr>
</tbody>
</table>
</body>
</html>';
}
public function footer()
{
return "<h2>Footer Fatherfucker</h2>";
}
public function pdf($id)
{
// return 'fuck';
// $document = GeneratedDocument::findOrFail($id);
// $pdf = PDF::loadFile('http://localhost:8000/');
// $pdf = PDF::loadFile('http://aso-linksehat.local/');
// return $pdf->inline();
// dd(route('generated-document.show', $id));
// $pdf = PDF::loadFile(route('generated-document.show', $id));
// return $pdf->inline();
// $pdf = PDF::loadHtml('<h1>Motherfucker</h1>');
// $snappy = App::make('snappy.pdf');
// $html = '<h1>Bill</h1><p>You owe me money, dude.</p>';
// // $snappy->generateFromHtml($html, '/tmp/bill-123.pdf');
// // $snappy->generate('http://www.github.com', '/tmp/github.pdf');
// //Or output:
// return new Response(
// $snappy->getOutputFromHtml($html),
// 200,
// array(
// 'Content-Type' => 'application/pdf',
// 'Content-Disposition' => 'attachment; filename="file.pdf"'
// )
// );
$pdf = PDF::loadFile(route('generated-document.show', $id));
// $pdf->loadFile(route('generated-document.show', $id));
// $pdf->loadFile(route('generated-document.show', $id));
// $pdf->loadFile(route('generated-document.show', $id));
// $pdf->loadFile(route('generated-document.show', $id));
// $pdf->setPaper('a4')->setOrientation('landscape')->setOption('margin-bottom', 0);
// $pdf->setOption('header-html', route('pdf.header'));
// $pdf->setOption('footer-html', route('pdf.header'));
// $pdf->setOption('footer-center', 'asdasdasd');
// $pdf->setOption('footer-html', route('pdf.footer'));
// $pdf->loadHtml('asdasdasd');
return $pdf->inline();
}
}