0
I have the following content HTML being generated in a loop PHP
$html .= "
<ul class='border'>
<li style='text-align: left; border-bottom: .1px rgb(0,0,0) solid;'><label class='labelPequeno'>Gcéu</label> : " . $celula[ "nomeCelula" ] . "</li>
<li style='text-align: left; border-bottom: .1px rgb(0,0,0) solid;' class='backCinza'><label class='labelPequeno'>Supervisor de Setor</label> : " . $nomeLideres[ "nomeLiderSetor" ] . "</li>
<li style='text-align: left; border-bottom: .1px rgb(0,0,0) solid;'><label class='labelPequeno'>Líder</label> : " . $celula[ "nomeLider" ] . "</li>
<li style='text-align: left;'><label class='labelPequeno'>Auxiliar</label> : " . $celula[ "nomeAuxiliar" ] . "</li>
</ul>
<ul class='border'>
<li style='text-align: left; border-bottom: .1px rgb(0,0,0) solid;'><label class='labelPequeno'>Dias que acontece</label> : " . $celula[ "diaReunioes" ] . "</li>
<li style='text-align: left;'><label class='labelPequeno'>Membros Ativos</label> : " . $membros . "</li>
</ul>";
This happens in the page x php. for example.
On that same page x php. there is a form that sending, via POST, a field Hidden with the value being the variable above created with your content for a page who will generate an archive pdf.
I’m generating PDF’s with the code below using the library FPDF
require_once "_classes/_util/_PDF/PDF.php";
$html = $_POST["htmlPDF"];
$pdf = new PDF;
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->WriteHTML( utf8_decode ( $html ) );
$pdf->Output("relatorio.pdf","D");
It turns out that in this file I can’t insert calls to style files.
The problem:
$_POST["htmlPDF"]
Brings a HTML .
In that case, the pdf is leaving without style.
Does there exist a way when being generated to variable that contain the html, enjoy and insert via code (dynamically) the styles straightforward in tags?
Well, come on. I have a foreach that generates an html structure. Okay? I have a form with an Hidden input with HTML content without the proper Styles embedded in the tags. Okay? This form takes the Valu from Input Hidden to a page that has the code that is in the question. I added the css files before the php block and it went bad. So I wanted to know if there is some kind of $pdf->Setcss and send the linl of the file..
– Carlos Rocha
@Carlosrocha will not know how to tell you, what I can say, is that even if it is not a very indicated practice you can include the tag link with your file . css right inside the body tag, does not need to be exclusively inside the head tag. (although inside the head tag is advisable)
– hugocsl
in the file that contains the call to the library can aenas the HTML output. You cannot put the style
– Carlos Rocha
@Carlosrocha you will not put
style
you’ll put<link rel="stylesheet" href="../seu.css" />
somewhere there.... I don’t know if it will work, it’s just a hint, and it’s allowed by W3C, already by the API you’re using I don’t know if it works...– hugocsl