barryvdh / laravel-dompdf

A DOMPDF Wrapper for Laravel
MIT License
6.67k stars 967 forks source link

how can i use page-break-after: always; for table in laravel ? #193

Closed hamelraj89 closed 4 years ago

hamelraj89 commented 8 years ago

im getting error so if i use page-break i can solve this but i don't know how to use i tried many way but it won't work

DOMPDF_Exception in cellmap.cls.php line 244:
Frame not found in cellmap

My method -

public function invoice($id){
        $job = Job::find($id);
        $sum = DB::table('charges')
            ->where('job_id', $job->id)
            ->sum('amount');
        $charges = Charge::select('charges.*','consignees.name')
            ->leftJoin('jobs','jobs.id','=','charges.job_id')
            ->leftJoin('consignees','consignees.id','=','jobs.consignee_id')
            ->where('job_id', $job->id)
            ->get();
        $invoice = DB::table('jobs')
            ->where('id',$id)
            ->sum('invoice_value');
        $total = $sum - $invoice ;
        $pdf = \PDF::loadView('jobs.invoice',compact('job','sum','charges','total'));
        return $pdf->download('invoice.pdf');
    }

my invoice -

 <tbody>
        <?php $i=0 ?>
        @foreach($charges as $expense)
            <?php $i++ ?>
            <tr>

                <td class="id">{!! $expense->id !!}</td>
                <td class="date">{!! $expense->date!!}</td>
                <td class="charge">{!! $expense->charge!!}</td>
                <td class="cat">{!! $expense->category!!}</td>
                <td class="amount">{!! $expense->amount!!}</td>

            </tr>

        @endforeach
        <tr>
            <td colspan="4">TOTAL EXPENSES</td>
            <td class="total">{!!  $sum !!}</td>
        </tr>
        <tr>
            <td colspan="4">INVOICE VALUE</td>
            <td class="total">{!! $job->invoice_value!!}</td>
        </tr>
 </tbody>
suarezph commented 8 years ago

Pravansik,

I share to you on how it will break nicely and cleanly:

if( $i % 10 == 0 ){ echo '<div class="breakNow"></div>'; .... }

In your css code:

div.breakNow { page-break-inside:avoid; page-break-after:always; }

I break the table on every 10, you can customize it in your own :)

hamelraj89 commented 8 years ago

Thanks its working :)

sayali05 commented 8 years ago

i tried but it wont work in my code and please give me suggestion?

hamelraj89 commented 8 years ago

This is the way to use page break. if you show your code can try to help you

<style>
.page-break {
    page-break-after: always;
}
</style>
<h1>Page 1</h1>
<div class="page-break"></div>
<h1>Page 2</h1>
sayali05 commented 8 years ago

Hi,

Thanks for your reply. But its not working in my code.

On Mon, Jul 25, 2016 at 4:46 PM, Hamelraj notifications@github.com wrote:

This is the way to page break if you show your code can try to help you

Page 1

Page 2

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/barryvdh/laravel-dompdf/issues/193#issuecomment-234926572, or mute the thread https://github.com/notifications/unsubscribe-auth/ATrxg0--qAIZxJzPutkoDyJx1Vrgqp9Dks5qZJsmgaJpZM4HY4PD .

hamelraj89 commented 8 years ago

Hi @sayali05 post ur questions stack or laracast tag me ? then can help

sayali05 commented 8 years ago

hi, there is so many issue in my dompdf page. First i want to set top margin in all page excluding first page. Is it possible.

hamelraj89 commented 8 years ago

bro @sayali05 if you really want solve ur issues just post ur questions somewhere. without showing your codes no one can't help u :( Add Margin Link

sayali05 commented 8 years ago

Where should i put my issue. Actually i am new for github. i dont know exactly what to do. Can you tell me.

hamelraj89 commented 8 years ago

post ur quz here http://stackoverflow.com/ or https://laracasts.com/

kapilpaul commented 6 years ago

@Pravinslk can you please give me an idea or can you please paste your codes so that I can get an Idea?

hamelraj89 commented 6 years ago

@kapilpaul if you installed laravel-dompdf then create view file in view path resource/view/invoice.blade.php then paste this code

<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
.page-break {
    page-break-after: always;
}
</style>
<body>

<h1>Page 1</h1>
<div class="page-break"></div>
<h1>Page 2</h1>

</body>
</html>

your route like this Route::get('/invoice', 'HomeController@createInvoice'); in your HomeController

public function createInvoice() {
$pdf = \PDF::loadView('invoice');
return $pdf->download('invoice.pdf');
}

this is basic try and let me know

salmankhanghori commented 6 years ago

XZX

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/dompdf/dompdf instead. When having doubts, please try to reproduce the issue with just dompdf. If you believe this is an actual issue with the latest version of laravel-dompdf, please reply to this issue so we can investigate further. Thank you for your contribution! Apologies for any delayed response on our side.

hamelraj89 commented 4 years ago

@aaesis aaesis has answered

ph4t0o0o0om commented 2 years ago

@hamelraj89 Hi I have same problem would you help me

ph4t0o0o0om commented 2 years ago

@aaesis Hi sir would you please help me? This is my problem . https://stackoverflow.com/questions/72371363/automatic-page-break-using-laravel-mpdf . thank you

hamelraj89 commented 2 years ago

@ph4t0o0o0om check your question Link

boyadmin commented 1 year ago

image

I have same problem ,table td rowspan

image