Skip to content

Commit 5959ebb

Browse files
committed
Update to release v1.0.3
1 parent dac9d4d commit 5959ebb

8 files changed

+41
-29
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.github export-ignore
2+
/.gitattributes export-ignore
3+
/.gitignore export-ignore

CHANGE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Change Log: `yii2-mpdf`
22
=======================
33

4+
## Version 1.0.3
5+
6+
**Date:** 04-Oct-2018
7+
8+
- Add .gitattributes.
9+
- Move all source code to `src` directory.
10+
- (bug #84): Fix bug with `$this->buffer`.
11+
- (enh #77): Correct headers already sent for "Download" & "Browser" destinations.
12+
- (bug #60): Correct missing `Mpdf::init` constructor params.
13+
414
## Version 1.0.2
515

616
**Date:** 22-Jun-2017

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 - 2017, Kartik Visweswaran
1+
Copyright (c) 2014 - 2018, Kartik Visweswaran
22
Krajee.com
33
All rights reserved.
44

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,4 @@ For other usage and details, read the detailed [documentation](http://demos.kraj
120120

121121
## License
122122

123-
**yii2-mpdf** is released under the BSD 3-Clause License. See the bundled `LICENSE.md` for details.
123+
**yii2-mpdf** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"homepage": "https://github.com/kartik-v/yii2-mpdf",
1414
"type": "yii2-extension",
15-
"license": "BSD 3-Clause",
15+
"license": "BSD-3-Clause",
1616
"authors": [
1717
{
1818
"name": "Kartik Visweswaran",
@@ -25,7 +25,7 @@
2525
},
2626
"autoload": {
2727
"psr-4": {
28-
"kartik\\mpdf\\": ""
28+
"kartik\\mpdf\\": "src"
2929
}
3030
},
3131
"extra": {

Pdf.php renamed to src/Pdf.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017
55
* @package yii2-mpdf
6-
* @version 1.0.2
6+
* @version 1.0.3
77
*/
88

99
namespace kartik\mpdf;
@@ -12,7 +12,7 @@
1212
use Yii;
1313
use yii\base\Component;
1414
use yii\base\InvalidConfigException;
15-
use yii\base\InvalidParamException;
15+
use yii\web\Response;
1616

1717
/**
1818
* The Pdf class is a Yii2 component that allows to convert HTML content to portable document format (PDF). It allows
@@ -145,7 +145,7 @@ class Pdf extends Component
145145
/**
146146
* @var string css file to prepend to the PDF
147147
*/
148-
public $cssFile = '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css';
148+
public $cssFile = '@vendor/kartik-v/yii2-mpdf/src/assets/kv-mpdf-bootstrap.min.css';
149149
/**
150150
* @var string additional inline css to append after the cssFile
151151
*/
@@ -254,6 +254,7 @@ public function initTempPaths()
254254
* Renders and returns the PDF output. Uses the class level property settings.
255255
*
256256
* @return mixed
257+
* @throws InvalidConfigException
257258
*/
258259
public function render()
259260
{
@@ -344,16 +345,16 @@ public function addPdfAttachment($filePath)
344345
* Calls the Mpdf method with parameters
345346
*
346347
* @param string $method the Mpdf method / function name
347-
* @param array $params the Mpdf parameters
348+
* @param array $params the Mpdf parameters
348349
*
349350
* @return mixed
350-
* @throws InvalidParamException
351+
* @throws InvalidConfigException
351352
*/
352353
public function execute($method, $params = [])
353354
{
354355
$api = $this->getApi();
355356
if (!method_exists($api, $method)) {
356-
throw new InvalidParamException("Invalid or undefined Mpdf method '{$method}' passed to 'Pdf::execute'.");
357+
throw new InvalidConfigException("Invalid or undefined Mpdf method '{$method}' passed to 'Pdf::execute'.");
357358
}
358359
if (!is_array($params)) {
359360
$params = [$params];
@@ -392,11 +393,11 @@ public function output($content = '', $file = '', $dest = self::DEST_BROWSER)
392393
}
393394
}
394395

395-
$is_web_response = (Yii::$app->response instanceof \yii\web\Response);
396+
$is_web_response = (Yii::$app->response instanceof Response);
396397

397398
// For non-web response, or for file / string output, use the mPDF function as it is
398399
if (!$is_web_response || in_array($dest, [self::DEST_FILE, self::DEST_STRING])) {
399-
return $api->Output($file, $dest);
400+
return $api->Output($file, $dest);
400401
}
401402

402403
// Workaround for browser & download output.
@@ -406,26 +407,24 @@ public function output($content = '', $file = '', $dest = self::DEST_BROWSER)
406407
// - Set the destination to string
407408
// - Set response headers through yii\web\Response
408409
$output = $api->Output($file, self::DEST_STRING);
409-
410410
$headers = Yii::$app->response->getHeaders();
411-
412-
$headers->set('Content-Type', 'application/pdf');
411+
$headers->set('Content-Type', 'application/pdf');
413412
$headers->set('Content-Transfer-Encoding', 'binary');
414-
$headers->set('Cache-Control', 'public, must-revalidate, max-age=0');
415-
$headers->set('Pragma', 'public');
416-
$headers->set('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
417-
$headers->set('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
413+
$headers->set('Cache-Control', 'public, must-revalidate, max-age=0');
414+
$headers->set('Pragma', 'public');
415+
$headers->set('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
416+
$headers->set('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
418417

419-
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) || empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
420-
// don't use length if server using compression
421-
$headers->set('Content-Length', strlen($output));
422-
}
418+
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) || empty($_SERVER['HTTP_ACCEPT_ENCODING'])) {
419+
// don't use length if server using compression
420+
$headers->set('Content-Length', strlen($output));
421+
}
423422

424-
if ($dest == self::DEST_BROWSER) {
425-
$headers->set('Content-Disposition', 'inline; filename="' . $file . '"');
426-
} else {
427-
$headers->set('Content-Disposition', 'attachment; filename="' . $file . '"');
428-
}
423+
if ($dest == self::DEST_BROWSER) {
424+
$headers->set('Content-Disposition', 'inline; filename="' . $file . '"');
425+
} else {
426+
$headers->set('Content-Disposition', 'attachment; filename="' . $file . '"');
427+
}
429428

430429
return $output;
431430
}
@@ -445,7 +444,7 @@ protected function parseFormat()
445444
/**
446445
* Appends the given attachment to the generated PDF
447446
*
448-
* @param Mpdf $api the Mpdf API instance
447+
* @param Mpdf $api the Mpdf API instance
449448
* @param string $attachment the attachment name
450449
*/
451450
private function writePdfAttachment($api, $attachment)
File renamed without changes.

0 commit comments

Comments
 (0)