2
I am using mPDF and it is only generating the reports correctly in Firefox or opening by IE. If I try to open the file with PDF reader it returns the failure error when loading PDF document.
<?php
include("../crud/_views/plugins/mpdf60/mpdf.php");
$html = "
teste
";
$mpdf = new mPDF('','', '', '', 55, 18, 19, 15, 0, 0, '');
$css = file_get_contents('../crud/_views/plugins/mpdf60/estilo.css');
$mpdf->WriteHTML($css,1);
$mpdf->WriteHTML($html,2);
$mpdf->Output('');
By the code I noticed that the error is generated on the line $mpdf->WriteHTML($css,1);
, if I remove it the PDF is displayed normally but does not stick to the css style.
css style file.
.titulo{
font-size: 14px;
font-family: Times, "Times New Roman";
font-weight: bold;
}
.sub-titulo{
font-size: 12px;
font-family: Times, "Times New Roman";
font-weight: bold;
}
.numero{
text-decoration: underline;
}
.direita{
text-align: right;
}
.center{
text-align: center;
}
.alinhamento{
margin-right: : 10%;
}
.direita{
text-align: right;
}
What version of MPF and what $css and $html content?
– Guilherme Nascimento
The latest version of the MPDF, the content is in the code, the $css is just the link reference, according to the mpdf https://mpdf.github.io/css-stylesheets/introduction.htmldocumentation
– Rafael Meirim
Last version is what? The mpdf has in more than one site to download, people think they are picking up on the official site when they are not and think it is the "last version" when it is not. Informs the exact version. And please, I’ve asked, inform the contents of
$html
.– Guilherme Nascimento
I have already solved with the answer below, thank you!
– Rafael Meirim
Rafael solved himself with the answer below, which has no logic with the explanation of the doc that indicates that there is some problem in the version you are using and so it is important to inform this kind of detail. Clearly the answer is only a palliative solution and does not explain why.
– Guilherme Nascimento
All right, the version is 6.0 taken from the site http://www.mpdf1.com/mpdf/index.php and using your manual as a reference. I edited the question with the full content of page q generates pdf
– Rafael Meirim
As I said, 6.0 is not the latest version, and as far as I know the site that officially distributes the MPDF is their own github repository: https://github.com/mpdf/mpdf/releases or via Composer (mpdf version 6.1 and 7 only). I edited my answer and restored it.
– Guilherme Nascimento
Rafael, as soon as I entered the mpdf1 site I saw the following messages: Updated 16/03/2016 - This mPDF website is now closed down. In other words, this site is inactive, unlike the github whose mpdf author keeps keeping the updates and fixes. I added it to the body of the reply. Note: When your HTML does not have the <HEAD> tag then it is necessary to use the second parameter with the value
2
– Guilherme Nascimento
I’ve updated the answer with all the details, so you can imagine that I’m getting on your bad side or your nagging, but that’s not it. The reason is that you received a good response from Samuel, but I noticed the problem that can be more serious, you are using an outdated version of which can contain Bugs and this would cause you problems, so I insist on the reply and comments I sent you, because sometimes things are more complex and my intention is to help you showing where is the serious problem of using a tool that can contain BUGS.
– Guilherme Nascimento