Skip to content

Commit

Permalink
Merge pull request #2 from PeerJ/AddConstructor
Browse files Browse the repository at this point in the history
Add a constructor to mPDF to allow for additional font configuration to ...
  • Loading branch information
Patrick McAndrew committed Dec 9, 2014
2 parents fdd784e + 3552b0a commit 5d05283
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
mpdf
====

This is a fork of Ian Back's mPDF code found at
http://www.mpdf1.com/mpdf/index.php

Currently, using v5.2 as appears to be the most stable.

Note that this fork now deviates a bit in order to add additional font data without chaging the code.

Usage:

```
$mpdf = new mPDF(array("unifont" => array('R' => "unifont.ttf")));
$mpdf->mPDF('s');
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "PeerJ/mpdf",
"name": "peerj/mpdf",
"type": "library",
"description": "mPDF is a PHP class which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number of enhancements. (V 5.7.2)",
"keywords": ["php", "pdf", "utf-8"],
Expand Down
20 changes: 18 additions & 2 deletions mpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,21 @@ class mPDF
// **********************************
// **********************************

/*
* Allow additional fontdata without adding to config_fonts.php
* usage:
* $mpdf = new mPDF(array('unifont' => array('R' => "unifont.ttf")));
* $mpdf->mPDF('s');
*
*/
function __construct($fontdata = array())
{
require(_MPDF_PATH.'config_fonts.php');
foreach($fontdata as $name => $data) {
$this->fontdata[$name] = $data;
}
}

function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {

/*-- BACKGROUNDS --*/
Expand Down Expand Up @@ -1133,7 +1148,8 @@ function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=1
$this->SetDisplayPreferences('');

// Font data
require(_MPDF_PATH.'config_fonts.php');
// Moved to __contruct()
// require(_MPDF_PATH.'config_fonts.php');
// Available fonts
$this->available_unifonts = array();
foreach ($this->fontdata AS $f => $fs) {
Expand Down Expand Up @@ -32802,4 +32818,4 @@ function SetJS($script) {



?>
?>

0 comments on commit 5d05283

Please sign in to comment.