0

I need a pdf to be generated with name being placed on top of an image at a particular place. I have written a working HTML code but mpdf is unable to load the stylesheets and the name is getting printed below the image.

Here is my code of php:

<?php
$html = file_get_contents('index12.html');

require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new \Mpdf\Mpdf();
$stylesheet = file_get_contents('style.css');
$mpdf->WriteHTML($stylesheet, 1);

$mpdf->WriteHTML($html,2);
$mpdf->Output();

index12.html

<!-- <link rel="stylesheet" href="style.css"> -->

<div class="image">

      <img src="yugmak.jpg" alt="" />

      <h2>Kung Fu Panda</h2>

</div>

style.css

@font-face {
  font-family: "Montez";
  src: url("Montez.ttf");
}

.image {
 position: relative;
 width: 100%; /* for IE 6 */
}

h2 {
 position: absolute;
 font-family: "Montez";
 font-size: 250px;
 top: 2100px;
 padding-left: 1050px;
 width: 2000px;
}

Any way to make the css work in pdf would be great.

3
  • you need include this include('mpdf.php'); after your html template Commented Apr 30, 2018 at 17:02
  • Possible duplicate of how to add css file in mpdf Commented Apr 30, 2018 at 17:33
  • @Tegito123 including the given snippet did not make any difference. Commented Apr 30, 2018 at 18:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.