Closed githubjeka closed 10 years ago
Try removing all mpdf references in your repositories
section in composer.json
file and just put: "robregonm/yii2-pdf": "dev-master"
into require
section. This will use the latest version of mpdf by default.
my composer.json
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-imagine": "*",
"yiisoft/jquery": "~1.10",
"yiisoft/yii2-jui": "*",
"2amigos/yii2-grid-view-library": "*",
"robregonm/yii2-pdf": "dev-master"
},
mpdf version is latest 5.7.3. And my code does not work. If setted version 5.7.2 then my code works.
Do you have repositories
block into your composer.json
file?
No
I add in my composer.json. It work fine, but why <em>
and other some tags not work with new version 5.7.3 from render view file?
"require": {
"robregonm/yii2-pdf": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"name": "robregonm/yii2-pdf",
"version": "dev-master",
"source": {
"url": "https://github.com/robregonm/yii2-pdf",
"type": "git",
"reference": "ff3a6e7"
},
"require": {
"mpdf/mpdf": "5.7.2"
},
"autoload": {
"psr-4": {
"robregonm\\pdf\\": ""
}
}
}
}
]
Please remove the repositories
block, it is not necessary for yii-pdf2
nor mpdf
to work
Also, please check that your files are utf8 encoded.
When "mpdf/mpdf": "5.7.2" then my code works . When "mpdf/mpdf": "5.7.3" then the code does not work. Why? My files is same, not changed.
The problem appeared after upgrade "mpdf/mpdf" to latest version 11 days ago.
Please try to have a code
//SiteController
public function actionIndex()
{
Yii::$app->response->format = 'pdf';
$this->layout = '//print';
return $this->render('report');
}
<?php
/* @var $content */
$this->beginPage() ?>
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<?php $this->beginBody() ?>
<?= $content ?>
<?php $this->endBody() ?>
</body>
</html>
<?php
$this->endPage();
//report
<p class="text-right"><em>Title</em></p>
I test on a big view file, and I use all kind of HTML tags (even mpdf-only tags).
This error is pretty weird because by default yii-pdf uses lates version of mpdf ("mpdf/mpdf": "dev-master"
).
I'll test using specific version in order to see what happens.
I executed a quick test and no issues so far.
Take a look to composer.json
file I use for a personal project where I'm using yii2-pdf
package:
"minimum-stability": "dev",
"repositories": [
{
"type": "package",
"package": {
"name": "ace-editor",
"version": "1.1.2",
"source": {
"url": "https://github.com/ajaxorg/ace-builds.git",
"type": "git",
"reference": "master"
}
}
},
{
"type": "package",
"package": {
"name": "cropper",
"version": "0.3.0",
"source": {
"url": "https://github.com/fengyuanchen/cropper.git",
"type": "git",
"reference": "master"
}
}
},
],
"require": {
"php": ">=5.5.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-redis": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-jui": "*",
"robregonm/yii2-auth": "*",
"cebe/yii2-gravatar": "*",
"FortAwesome/Font-Awesome": "*",
"ckeditor/ckeditor": "*",
"ace-editor": "*",
"cropper": "*",
"bootstrap-select/bootstrap-select": "*",
"twig/twig": "*",
"twitter/typeahead.js": "dev-master",
"yiisoft/yii2-imagine": "*",
"robregonm/yii2-pdf": "dev-master"
},
Please compare, and tell me if it still fails for you. Also, please ensure you are using UTF8 encoding in your files.
It seems that this is a mpdf related bug. Please report it in mpdf1.com/forum Thanks.
$mpdf->WriteHTML('<em>Title</em>');
it code works. From view the code oes not work, i wrote above. Okay, i will look to find problem.
I caught a bug https://github.com/finwe/mpdf/issues/28
My last version which works
Now mpdf version ace190986978df40b9c416cf7ba8761945fc1758 and my code
outputs
If del tag
<em>
then it works.The code works:
Whats wrong?