Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoice style not applied #51

Closed
youssef-ghrib opened this issue Nov 16, 2020 · 4 comments
Closed

Invoice style not applied #51

youssef-ghrib opened this issue Nov 16, 2020 · 4 comments

Comments

@youssef-ghrib
Copy link

youssef-ghrib commented Nov 16, 2020

For some reason bootstrap is not working in the generated pdf.
This is my code:

$client = new Party([
            'name'          => $request->receiver,
            'phone'         => $request->phone_no_1,
            'address'       => $request->address.', '.$request->postal_code.' '.$request->deligation,
        ]);

        $customer = new Party([
            'name'          => 'Ashley Medina',
            'address'       => 'The Green Street 12',
            'code'          => '#22663214',
            'custom_fields' => [
                'order number' => '> 654321 <',
            ],
        ]);

        $items = [
            (new InvoiceItem())->title($request->packet)->pricePerUnit($request->price)->quantity($request->quantity)
        ];

        $notes = [$request->note];
        $notes = implode("<br>", $notes);

        $invoice = Invoice::make('receipt')
            ->seller($client)
            ->buyer($customer)
            ->date(now()->subWeeks(3))
            ->currencySymbol('')
            ->currencyCode('DT')
            ->currencyThousandsSeparator('.')
            ->currencyDecimalPoint(',')
            ->filename('test')
            ->addItems($items)
            ->notes($notes)
            ->logo(public_path('vendor/invoices/logo.png'))
            // You can additionally save generated invoice to configured disk
            ->save('public');

This is my generated pdf:

test.pdf

PS: I am using Laravel 8 and laravel-invoices 2.0

@jwiegant
Copy link

jwiegant commented Nov 17, 2020

@youssef-ghrib I think the wrong template will be installed when you use php artisan invoices:install. If you do php artisan invoices:update after the install the correct template will be added. That worked for me.

@youssef-ghrib
Copy link
Author

I tried php artisan invoices:update but still same issue.

@jwiegant
Copy link

jwiegant commented Nov 18, 2020

Strange. Use the following as the head of your template, that's works for me.

<head>
    <title>{{ $invoice->name }}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <style type="text/css" media="screen">
        html {
            font-family: sans-serif;
            line-height: 1.15;
            margin: 0;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
            font-weight: 400;
            line-height: 1.5;
            color: #212529;
            text-align: left;
            background-color: #fff;
            font-size: 10px;
            margin: 36pt;
        }

        h4 {
            margin-top: 0;
            margin-bottom: 0.5rem;
        }

        p {
            margin-top: 0;
            margin-bottom: 1rem;
        }

        strong {
            font-weight: bolder;
        }

        img {
            vertical-align: middle;
            border-style: none;
        }

        table {
            border-collapse: collapse;
        }

        th {
            text-align: inherit;
        }

        h4, .h4 {
            margin-bottom: 0.5rem;
            font-weight: 500;
            line-height: 1.2;
        }

        h4, .h4 {
            font-size: 1.5rem;
        }

        .table {
            width: 100%;
            margin-bottom: 1rem;
            color: #212529;
        }

        .table th,
        .table td {
            padding: 0.75rem;
            vertical-align: top;
            border-top: 1px solid #dee2e6;
        }

        .table thead th {
            vertical-align: bottom;
            border-bottom: 2px solid #dee2e6;
        }

        .table tbody + tbody {
            border-top: 2px solid #dee2e6;
        }

        .mt-5 {
            margin-top: 3rem !important;
        }

        .pr-0,
        .px-0 {
            padding-right: 0 !important;
        }

        .pl-0,
        .px-0 {
            padding-left: 0 !important;
        }

        .text-right {
            text-align: right !important;
        }

        .text-center {
            text-align: center !important;
        }

        .text-uppercase {
            text-transform: uppercase !important;
        }

        * {
            font-family: "DejaVu Sans";
        }

        body, h1, h2, h3, h4, h5, h6, table, th, tr, td, p, div {
            line-height: 1.1;
        }

        .party-header {
            font-size: 1.5rem;
            font-weight: 400;
        }

        .total-amount {
            font-size: 12px;
            font-weight: 700;
        }

        .border-0 {
            border: none !important;
        }
    </style>
</head>

@youssef-ghrib
Copy link
Author

Works like a charm, Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants