我尝试使PDF编写CSS和HTML,但我的CSS不会出现在我的PDF。唯一要考虑的是字体大小和字体颜色。
我给你的代码(对不起,这有点长…)
$config = sfTCPDFPluginConfigHandler::loadConfig('my_config');
$doc_title = "Fiche Logement";
$html = <<
.informations {
padding: 10px;
margin: 10px;
border: 1px dotted black;}
.informations table {
margin-top: 10px;}
#modif {
margin: 20px;
text-align: left;
float: right;}
#modif th {
padding-left: 10px;}
#modif td {
padding-left: 10px;}
#adresse {
width: 307px;
float: left;}
#reservataire {
width: 307px;
float: right;}
#intergen {
width: 307px;
float: right;}
#infos {
width: 290px;
float: left;}
#handicap {
padding-bottom: 12px;
width: 324px;
float: right;}
#charges {
margin-bottom: 20px;
width: 307px;
float: left;}
#loyer {
width: 307px;
float: right;}
#commentaires {
clear: both;}
h2 {
font-variant: small-caps;
text-align: center;
font-size: 19px;
font-weight: bold;
padding: 0px 0px 2px 5px;
margin: 15px 0px 20px 0px;
color: #000000;
border-top: 1px dotted black;
border-bottom: 1px dotted black;}
h3 {
width: 250px;
font-variant: small-caps;
font-size: 15px;
font-weight: bold;
padding: 0px 0px 0px 5px;
margin: 0px;
color: #225D6D;
border-top: 1px dotted black;
border-bottom: 1px dotted black;}
Intergénérationnel
Intergénérationnel : | <?PHP echo \$logement->getIntergen() ?> |
---|
Informations logement
Bâtiment : | <?PHP echo \$logement->Parclogement->getBatiment() ?> |
---|---|
Taille : | <?PHP echo \$logement->getTaille() ?> |
Type : | <?PHP echo \$logement->getTypelog() ?> |
Surface habitable : | <?PHP if(\$logement->getSurfacehab() == 0){ echo 'Non Spécifié';} else {echo \$logement->getSurfacehab(). " m²";} ?> |
Chauffage : | <?PHP echo \$logement->getChauffage() ?> |
Ascenseur : | <?PHP echo \$logement->getAscenseur() ?> |
Infrastructures handicapés
Immeuble accessible : | <?PHP echo \$logement->getAccessibl() ?> |
---|---|
Ascenceur accessible : | <?PHP echo \$logement->getAscenseuracc() ?> |
Logement adaptable : | <?PHP echo \$logement->getAdaptable() ?> |
Logement adapté : | <?PHP echo \$logement->getAdapte() ?> |
EOF;
//create new PDF document (document units are set by default to millimeters)
$pdf = new sfTCPDF(PDF_PAGE_ORIENTATION,PDF_UNIT,PDF_PAGE_FORMAT,true);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetTitle($doc_title);
//set default header data
$pdf->SetHeaderData(PDF_HEADER_logo,PDF_HEADER_logo_WIDTH,PDF_HEADER_TITLE,PDF_HEADER_STRING);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT,PDF_MARGIN_TOP,PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE,PDF_MARGIN_BOTTOM);
//set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN,'',PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA,PDF_FONT_SIZE_DATA));
//set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// Fixe la taille de la page
$pdf->SetDisplayMode(90);
//initialize document
$pdf->SetFont('helvetica',10);
$pdf->AddPage();
// output some HTML code
$pdf->writeHTML($html,true,false,'');
//reset pointer to the last page
$pdf->lastPage();
// Close and output PDF document
$pdf->Output('fichelogement.pdf','I');
// Stop symfony process
throw new sfStopException();