Shreeraj Karki
Shreeraj Karki

Reputation: 238

DomPDF loads font in local but not online

I want to use Arial as the font for my PDF. But it only works in a local site, but not online. I am doing this project with Codeigniter. Below is my code.

 @font-face {
    font-family: "arial";
    src: url('<?php  echo admin_asset_url();?>/arial.ttf');
   }
 body,h1,h2,h3,li,a,p,h4{
        font-family: "arial";
    }
function pdf_create($html, $filename='', $stream=TRUE) 
{
    require_once("dompdf/dompdf_config.inc.php");

    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename.".pdf");
    } else {
        return $dompdf->output();
    }
}

Upvotes: 0

Views: 1476

Answers (1)

Philip G
Philip G

Reputation: 4104

This is probably because domPDF is loading the font from your server witch, when accessing your localhost, probably is your computer.

Your server on the other hand probably don't have arial installed. Hence it is not working.

Se this link for more info on domPDF and fonts

Upvotes: 1

Related Questions