İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
|
||||
function file_force_contents( $fullPath, $contents, $flags = 0 ){
|
||||
$parts = explode( '/', $fullPath );
|
||||
array_pop( $parts );
|
||||
$dir = implode( '/', $parts );
|
||||
|
||||
if( !is_dir( $dir ) )
|
||||
mkdir( $dir, 0777, true );
|
||||
|
||||
file_put_contents( $fullPath, $contents, $flags );
|
||||
}
|
||||
function pdf_create($path, $html)
|
||||
{
|
||||
$pdf = App::make('dompdf.wrapper');
|
||||
$pdf->setPaper('A4',$j['paper']);
|
||||
$pdf->setOption(['dpi' => $j['dpi'], ]);
|
||||
$pdf->loadHTML($html);
|
||||
|
||||
$path = "$path.pdf";
|
||||
|
||||
Storage::delete($path);
|
||||
Storage::put($path, $pdf->output());
|
||||
}
|
||||
|
||||
function html_create($path, $html, $paper="portrait")
|
||||
{
|
||||
$path = "$path.html";
|
||||
Storage::delete($path);
|
||||
Storage::put($path, $html);
|
||||
|
||||
|
||||
$htmlPath = "storage/documents/" . $path;
|
||||
$pdfPath = str_replace(".html", ".pdf", $htmlPath);
|
||||
html_to_pdf($htmlPath, $pdfPath, $paper);
|
||||
unlink($htmlPath);
|
||||
} ?>
|
||||
Reference in New Issue
Block a user