user14232549
user14232549

Reputation: 413

How to output PDF by HTML with CSS in Laravel project

I am looking for a way to create PDF from (BLADE )HTML with CSS

I am using this.

"barryvdh/laravel-dompdf": "^0.8.7",

but its output looks misconversion.

        $pdf = PDF::loadView('test'
        )->setPaper('a4', 'portrait');
        return $pdf->stream("aaa.pdf");

I use this html

https://github.com/okoppe8/PaperFormToHTML

result here.

enter image description here

Upvotes: 0

Views: 156

Answers (1)

John Lobo
John Lobo

Reputation: 15319

Use Custom font to display.So download simhei.ttf from any source.and place it public folder.Then you can use below css

<style type="text/css">
        @font-face {
            font-family: SimHei;
            src: url('simhei.ttf') format('truetype');
        }

        * {
            font-family: SimHei;
        }
    </style>

As per github issue Ref:https://github.com/barryvdh/laravel-dompdf/issues/198

Download font from https://www.wfonts.com/font/simhei

Upvotes: 1

Related Questions