Dynamic hight for Recordsets in PDF-Report

Hi,
how is it possible to get a dynamic hight for recordsets in a PDF-Report?
In my recordset is a multiline field with formatted text,
one recordset uses 1 line
some recordsets more, lets say 10 lines.
if I set the hight to small, the recordsets are overlapping,
if I set the hight to large, most of the page is blank.
I want, that each recordset uses only so many lines of the page which it needs.

Now I use different print-Buttons with different recordset-hights,
but that is not a solution:

                switch ($myHight) {
                    case "mikro":
                        sc_pdf_sub_sel_end(6);
                        break;
                    case "mini":
                        sc_pdf_sub_sel_end(11);
                        break;
                    case "klein":
                        sc_pdf_sub_sel_end(16);
                        break;
                    case "mittel":
                        sc_pdf_sub_sel_end(20);
                        break;
                    case "gross":
                        sc_pdf_sub_sel_end(32);
                        break;
                    default:
                        sc_pdf_sub_sel_end(26);
                        break;
                }

I found a try to manipulate the cursor position on the page with that:

$j = sc_pdf_get_y();
sc_pdf_set_y($j+30);

but this position seems NOT to be the position the the last pixel was set,
but where the last recordset was started to print.

Thanks for any ideas how this can be solved.
Frederic Espitalier

I just saw my old post here, I solved that problem, in anybody is interested, just ask
frederic

Im interested in your solution :slight_smile:

Hi frederic, i have exactly the same problem. a lot of lines in the text field and overlapping by pdf, Im realy interested

regards from Switzerland
Salvatore Reinemuth

That would be really nice, but does static height work??
Whatever I set as Line Height in “PDF Report Settings” is honored only on the first page.
Then all remaining records are clusterd as a single record on page 2, as shown here (that’s the actual output on page 2, not altered by me).

UPDATE: I’m using a single field (populated onRecord, with html tags for bold and line breaks) and this issue appears only when using sc_pdf_print_html, i.e. the field has “Show HTML content” off.

[ATTACH=JSON]{“alt”:“Click image for larger version Name: sc_pdf2.png Views: 0 Size: 98.6 KB ID: 90283”,“data-align”:“none”,“data-attachmentid”:“90283”,“data-size”:“full”,“title”:“sc_pdf2.png”}[/ATTACH]

sc_pdf2.png

Hi, I did not noticed that there was interest,
I just watched my code, so far I understand my code, I wrote 2 functions to get the hight of a multilinetext
What I do is writing the field into a temporary pdf document and than I can see how much the vertical cursor position changed
If You want I can document it a and post it, now without documentation:


function multiline_get_textfieldheight($field, $index)
    {    multiline_get_parameters($field, $index, $multilinetext, $width, $posX, $fontHight, $fontName);

        $pdf1 = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        $pdf1->setImageScale(PDF_IMAGE_SCALE_RATIO);
        $pdf1->SetFont($fontName, '', $fontHight);
        $pdf1->AddPage();
        $pdf1->writeHTMLCell($width, 0, $x, $y, $multilinetext, $border=0, $ln=0, $fill=0, $reseth=false, $align='', $autopadding=false);

         return  $pdf1->getLastH();
    }

function multiline_get_parameters($field, $index, &$multilinetext, &$width, &$posX, &$fontHight, &$fontName)
    {        $multilinetext = $field['data'][$index];
                    $width = $field['width'];
                     $posX = $field['posx'];
                $fontHight = $field['font_size'];
                 $fontName = $field['font_type'];
    }


I put those functions into the code of the report,
here is how I called them:

$cell_rechnungspositionText, ist the object which of the multiline text (html)

to get the height of the block first for checking if there is enough space on the page:


$currentlineheight = multiline_get_textfieldheight( $cell_rechnungspositionText, $NM_ind);

and later on:


        multiline_get_parameters($cell_rechnungspositionText, $NM_ind, $multilinetext, $width, $posX);
        $pdf->writeHTMLCell($width, 0, $posX, $y, $multilinetext, $border=0, $ln=0, $fill=0, $reseth=false, $align='', $autopadding=true);

// and than I have to move the vertical cursor:

        $pdf->SetY($pdf->GetY()+$currentlineheight);


Did that help?

Frederic