Add font and configuration for dompdf
This commit is contained in:
parent
abd55133f1
commit
e72561278b
@ -14,6 +14,8 @@ use App\Jobs\Document\UpdateDocument;
|
||||
use App\Models\Document\Document;
|
||||
use App\Notifications\Sale\Invoice as Notification;
|
||||
use App\Traits\Documents;
|
||||
use Dompdf\Dompdf;
|
||||
use Dompdf\Options;
|
||||
|
||||
class Invoices extends Controller
|
||||
{
|
||||
@ -289,21 +291,35 @@ class Invoices extends Controller
|
||||
*/
|
||||
public function pdfInvoice(Document $invoice)
|
||||
{
|
||||
define("DOMPDF_UNICODE_ENABLED", true);
|
||||
mb_internal_encoding('UTF-8');
|
||||
|
||||
$options = new Options();
|
||||
$options->set('defaultFont', 'Noto Sans');
|
||||
|
||||
$dompdf = new Dompdf($options);
|
||||
$dompdf->set_option('defaultMediaType', 'all');
|
||||
$dompdf->set_option('isFontSubsettingEnabled', true);
|
||||
$dompdf->setPaper('A4', 'portrait');
|
||||
|
||||
|
||||
$file_name = $this->getDocumentFileName($invoice);
|
||||
|
||||
event(new \App\Events\Document\DocumentPrinting($invoice));
|
||||
|
||||
$currency_style = true;
|
||||
|
||||
$view = view($invoice->template_path, compact('invoice', 'currency_style'))->render();
|
||||
|
||||
$html = mb_convert_encoding($view, 'HTML-ENTITIES', 'UTF-8');
|
||||
|
||||
$pdf = app('dompdf.wrapper');
|
||||
$pdf->loadHTML($html);
|
||||
$dompdf = app('dompdf.wrapper');
|
||||
|
||||
//$pdf->setPaper('A4', 'portrait');
|
||||
$dompdf->loadHTML($html, 'UTF-8');
|
||||
|
||||
$file_name = $this->getDocumentFileName($invoice);
|
||||
// return $pdf->download($file_name);
|
||||
|
||||
return $pdf->download($file_name);
|
||||
return $dompdf->stream();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +78,7 @@ return [
|
||||
/**
|
||||
* Whether to enable font subsetting or not.
|
||||
*/
|
||||
"enable_font_subsetting" => false,
|
||||
"enable_font_subsetting" => true,
|
||||
|
||||
/**
|
||||
* The PDF rendering backend to use
|
||||
@ -151,7 +151,7 @@ return [
|
||||
* Used if no suitable fonts can be found. This must exist in the font folder.
|
||||
* @var string
|
||||
*/
|
||||
"default_font" => "DejaVu Sans, sans-serif",
|
||||
"default_font" => "",
|
||||
|
||||
/**
|
||||
* Image DPI setting
|
||||
|
BIN
public/css/fonts/NotoSans-Regular.ttf
Normal file
BIN
public/css/fonts/NotoSans-Regular.ttf
Normal file
Binary file not shown.
13
public/css/print.css
vendored
13
public/css/print.css
vendored
@ -1,11 +1,22 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
/*--General Start--*/
|
||||
|
||||
@font-face {
|
||||
font-family: 'Noto Sans';
|
||||
src: url("public/fonts/NotoSans-Regular.ttf") format("truetype");
|
||||
}
|
||||
|
||||
|
||||
* {
|
||||
font-family: 'Noto Sans', sans-serif !important;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: Arial, sans-serif;
|
||||
font-family: 'Noto Sans';
|
||||
color: #3c3f72;
|
||||
}
|
||||
|
||||
|
BIN
public/vendor/opensans/fonts/NotoSans-Bold.ttf
vendored
Normal file
BIN
public/vendor/opensans/fonts/NotoSans-Bold.ttf
vendored
Normal file
Binary file not shown.
BIN
public/vendor/opensans/fonts/NotoSans-BoldItalic.ttf
vendored
Normal file
BIN
public/vendor/opensans/fonts/NotoSans-BoldItalic.ttf
vendored
Normal file
Binary file not shown.
BIN
public/vendor/opensans/fonts/NotoSans-Italic.ttf
vendored
Normal file
BIN
public/vendor/opensans/fonts/NotoSans-Italic.ttf
vendored
Normal file
Binary file not shown.
BIN
public/vendor/opensans/fonts/NotoSans-Regular.ttf
vendored
Normal file
BIN
public/vendor/opensans/fonts/NotoSans-Regular.ttf
vendored
Normal file
Binary file not shown.
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8; charset=ISO-8859-1"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8;"/>
|
||||
|
||||
<title>@yield('title') - @setting('company.name')</title>
|
||||
|
||||
@ -14,14 +14,20 @@
|
||||
<link rel="icon" href="{{ asset('public/img/favicon.ico') }}" type="image/png">
|
||||
|
||||
<!-- Css -->
|
||||
<link rel="stylesheet" href="{{ asset('public/css/print.css?v=' . version('short')) }}" type="text/css">
|
||||
|
||||
<style type="text/css">
|
||||
@font-face {
|
||||
font-family: "Noto Sans",
|
||||
src: url("{{ asset('public/fonts/NotoSans-Regular.ttf') }}") format("truetype");
|
||||
}
|
||||
|
||||
* {
|
||||
font-family: DejaVu Sans, sans-serif !important;
|
||||
font-family: 'Noto Sans', sans-serif !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" href="{{ asset('public/css/print.css?v=' . version('short')) }}" type="text/css">
|
||||
|
||||
@stack('css')
|
||||
|
||||
@stack('stylesheet')
|
||||
|
Loading…
x
Reference in New Issue
Block a user