1
I am having a problem with the header in relation to the body text while generating a PDF.
The header is being overwritten by the body text, how to resolve this?
I’m using the method SetHTMLHeader
for the header and the methodWriteHTML
for the body text. Is there any way to increase the size reserved for the header with that library, or something else that solves?
My current code:
<?php
session_start();
include('mpdf60/mpdf.php');
$paragrafo = "";
for($x=1;$x<=12;$x++){
$paragrafo.=$_SESSION['c'.$x]."<br/>";
}
$cabecalho = $_POST['cabecalho'];
$mpdf=new mPDF();
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($cabecalho);
$mpdf->WriteHTML($paragrafo);
$mpdf->Output();
exit;?>
How I wanted you to stay:
How are you getting:
You can put the code here?
– Giancarlo Abel Giulian
@Giancarloabelgiulian put here
– alexandre9865
The code that makes up the text is just that?
– user28595
@Diegofelipe put the beginning of the code now
– alexandre9865
this is the complete code of the file that mounts the pdf @Diegofelipe
– alexandre9865
Well, you’re not setting the print position on the page, you’re just having "print" a lot of stuff. It’s not the library that will guess where you want the texts, right?
– Bacco
but where do I do it? didn’t understand the documentation of this library @Bacco
– alexandre9865
@Alexandremartinsmontebelo has no example of how to position the information in the documentation? Maybe in one of these answers you have something that can be used (I didn’t read it, it’s just a research suggestion) http://answall.com/search?q=mpdf+is%3Aquestion - Anyway, let’s wait if someone posts an answer that helps. In the meantime, if you can, take a peek at the examples.
– Bacco
Looking quickly, it seems to me that when creating the PDF, you can specify the page margins, but I don’t know if this would help. In English there are solutions with CSS, maybe serve as a starting point. http://stackoverflow.com/questions/16538109/change-top-margin-of-second-page-using-mpdf Another thing you might want to do is add the header material to the body of the page. Maybe it’s not the most elegant way.
– Bacco
I tried this your second option first, to put everything in the body, only the header text was far below the expected, it looked like part of the body even, not with css solved, I’ll see if it’s right this first solution @Bacco
– alexandre9865
I got it! I changed the parameters when instantiating the mpdf class
– alexandre9865
@Alexandremartinsmontebelo I gave a formatted in your question, but since solved, you can post the solution as answer to your own question, in the field below.
– Bacco