Skip to content

Instantly share code, notes, and snippets.

@m5lil
Created January 5, 2019 15:40
Show Gist options
  • Save m5lil/e446dc3140bc7d460c2c293296494984 to your computer and use it in GitHub Desktop.
Save m5lil/e446dc3140bc7d460c2c293296494984 to your computer and use it in GitHub Desktop.
arabic pdf invoice
//install laravel-dompdf Package and arutil/ar-ph 

public function pdf($id)
{
  $data = Invoice::find($id);
  $pdf = \PDF::loadView('invoice', ['data' => $data]);
  return $pdf->stream('invoice.pdf');
}
<!doctype html>
<html lang="ar" dir="rtl">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Aloha!</title>

    <style type="text/css">
        * {
            font-family: dejavu sans, sans-serif;
            direction: rtl;
        }
        table{
            font-size: x-small;
        }
        tfoot tr td{
            font-weight: bold;
            font-size: x-small;
        }
        .gray {
            background-color: lightgray
        }
    </style>

</head>
@php $arabic = new ArUtil\I18N\Arabic('Glyphs') @endphp

<body style="direction: rtl;">

<table width="100%">
    <tr>
        <td valign="top">El Salam Compny</td>
        <td align="right">
            <h3>{{$arabic->utf8Glyphs(env('APP_NAME'))}}</h3>
            {{--<pre>--}}
                {{--Company representative name--}}
                {{--Company address--}}
                {{--Tax ID--}}
                {{--phone--}}
                {{--fax--}}
            {{--</pre>--}}
        </td>
    </tr>

</table>



<table width="100%">
    <tr  style="text-align: right">
        <td> {{ $data->invoice_no }} <strong> /  {{$arabic->utf8Glyphs('رقم الفاتورة')}}</strong></td>
        <td> {{ $arabic->utf8Glyphs($data->client_id) }} <strong> / {{$arabic->utf8Glyphs('للسيد ')}}</strong></td>
    </tr>
</table>

<br/>

<table width="100%" dir="rtl" style="direction: rtl">
    <thead style="background-color: lightgray;">
    <tr style="text-align: right">
        <th>{{ $arabic->utf8Glyphs('المبلغ الإجمالى') }}</th>
        <th>{{ $arabic->utf8Glyphs('سعر الوحدة') }}</th>
        <th>{{ $arabic->utf8Glyphs('العدد') }}</th>
        <th>{{ $arabic->utf8Glyphs('البيان') }}</th>
        <th >#</th>
    </tr>
    </thead>
    <tbody>
    @php $i = 1; @endphp
    @foreach($data->products as $product)
         <tr>
             <td align="right">{{ $product->total }}</td>
            <td align="right">{{ $product->price }}</td>
            <td align="right">{{ $product->qty }}</td>
            <td align="right">{{ $arabic->utf8Glyphs($product->item->name) }}</td>
            <th align="right" scope="row">{{$i}}</th>
        </tr>
        {{ $i++ }}
    @endforeach
    </tbody>

    <tfoot>
    <tr>
        <td align="right" colspan="3"></td>
        <td align="right">{{ $data->sub_total }}</td>
        <td align="right">{{ $arabic->utf8Glyphs('الجملة') }}</td>
    </tr>
    <tr>
        <td align="right" colspan="3"></td>
        <td align="right">{{ $data->discount }}</td>
        <td align="right">{{ $arabic->utf8Glyphs('الخصم') }}</td>
    </tr>
    <tr>
        <td colspan="3"></td>
        <td align="right" class="gray">{{ $data->grand_total }}</td>
        <td align="right">{{ $arabic->utf8Glyphs('المجموع') }}</td>
    </tr>
    </tfoot>
</table>

</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment