Hi all,
I’m trying to fix a Pdf Report that works as classic Invoice or Sales order, I mean a classic master/details example.
I got serious problems when I got many detailed rows to print for the same document and the page break is a buggy feature and not manageable at all. I did so many tests that I can’t imagine something else.
The other issue is when you fill in all the rows available in the first sheet and you have then to change the page and go to the second one. I can’t imagine how to do if the layout of second page is different from the first one.
By the way is there someone who has a working well sample application to share ? Only for the first part could be nice the same. Not say me that there is the tutorial or the sample of SC to see…
Thanks
Hello… i try to post a sample…
First, in sql, I’m access to master record (only one)
SELECT
Cod_InformeCaso
FROM
dbo.InformesCasos
Where Cod_InformeCaso = [Cod_InformeCaso]
Then, define a subset field
SELECT
TITULO,
VALOR,
NROORDEN,
INCLUYETITULO,
OBLIGATORIO
FROM
dbo.DetalleInformeCaso
Where Cod_InformeCaso = [Cod_InformeCaso]
Order By NroOrden
In layout PDF, Code, put this code…
function multiline_get_textfieldheight($field)
{
$pdf1 = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf1->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf1->SetFont('Helvetica', '', 10);
$pdf1->AddPage();
$pdf1->writeHTMLCell(190, 0, 0, $y, trim($field), $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true);
return $pdf1->getLastH();
}
$pdf->setFontSubsetting(false);
$pdf->SetFont('helvetica', '', 10, '', false);
$pagina = 0; //assign value to number of page only to manage pages
sc_pdf_sub_sel_init();
foreach ({DetalleInforme} as $NM_ind => $Dados)
{
$i = sc_pdf_get_y(); //get the "Y" position
if ($i > 245){ //in a letter page if the "Y" position if for research the end of the page create new page
sc_pdf_add_page('P', 'A4');
$i = 40; //assign new value to $i
$pagina++; //add one to pagina
}
sc_pdf_set_y($i); //assign a value to the "y" position
//
$Auxiliar = "";
if ($cell_DetalleInforme_INCLUYETITULO['data'][$NM_ind] = '1') {
$Auxiliar = trim($cell_DetalleInforme_TITULO['data'][$NM_ind]);
}
if (!empty(trim($cell_DetalleInforme_VALOR['data'][$NM_ind]))) {
//if (!empty(trim($Auxiliar))) {
// $Auxiliar = trim($Auxiliar)."<br>";
// }
$Auxiliar = trim($Auxiliar).trim($cell_DetalleInforme_VALOR['data'][$NM_ind]);
}
$currentlineheight = multiline_get_textfieldheight($Auxiliar);
$pdf->writeHTMLCell(190, 0, 0, $y, trim($Auxiliar), $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=false);
$pdf->SetY($pdf->GetY()+$currentlineheight);
//
sc_pdf_sub_sel_end();
}
´
Note, i’m print two deails fields, with in html…
I’m sure, you can adapt this code…
Hi and thanks for reply.
I’m not a programmer but it seems that the only way to make a master/detail report would be only by writing custom code.
If I understand there are no way with standard procedure.
Just a question. On setting did you set Records per line or Records per page ? It’s a bit confusing and the result normally is a mess of rows or bad page-breaks…
I will try your suggestion but it will take some time for me…
Bye
Sorry , I forgot …
I checked now your SQL for master section and you select only one document… It’s easier and in some way it works also for my temptation.
The big issue is when you try to print a range or all documents… It make a real mess with the page-breaks and lines…
Here is a sample of what I’m trying to achieve but … it’s a copy and paste of three single documents.