Alexander Yefremov
Alexander Yefremov

Reputation: 63

Laravel converting html page to pdf or docx

I have Ckeditor, inside what I put some text. At the end I have html code, what i must convert and put to pdf or docx files (better pdf). Firsly I tried to use Dompdf, but because of I had cyrillic symbols in my text and they do not display correctly.

Looks like this.

Maby someone know how to do it? Help please.

Upvotes: 0

Views: 2730

Answers (3)

Issam Ben Ameur
Issam Ben Ameur

Reputation: 249

Don't need to change this plugin, may be its encoding problem

Upvotes: 0

achillesp
achillesp

Reputation: 319

I've been using dompdf with greek characters without having any problems. You need to check the fonts provided with dompdf.

I load my own fonts using css in the html that is converted by dompdf.

I have also found this package to be useful (laravel-dompdf). It provides a wrapper for dompdf, so you can easily export a view as pdf.

Example of css to use for loading fonts:

<style>
    @font-face {
        font-family: 'OpenSans';
        font-style: normal;
        font-weight: 400;
        src: url('fonts/OpenSans-Regular.ttf')  format('truetype');
    }

    html, body {
        font-family: 'OpenSans';
    }
</style>

Upvotes: 0

Ajay Kumar
Ajay Kumar

Reputation: 1352

This might help you.

Package name is : mPDF

package : https://github.com/mpdf/mpdf

documentation : https://mpdf.github.io/

to installing via composer : composer require mpdf/mpdf

Upvotes: 1

Related Questions