Announcement

Collapse
No announcement yet.

How can I print more lines for each records using fields one under the other one

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I print more lines for each records using fields one under the other one

    Hello all,

    Is it possible to print a record using more lines for each singular record on the same page ?

    for istance 3 records on the same page split like that (more rows for each record)

    CODE_ID_01 PRODUCT_DESCRIPTION_01
    DATE_01 OTHER_FIELD_01
    FIELD00_01 OTHER_FIELD_0001

    CODE_ID_02 PRODUCT_DESCRIPTION_02
    DATE_02 OTHER_FIELD_02
    FIELD00_02 OTHER_FIELD_0002

    CODE_ID_03 PRODUCT_DESCRIPTION_03
    DATE_03 OTHER_FIELD_03
    FIELD00_03 OTHER_FIELD_0003


    Many thanks

  • #2
    For whom could be interested I did a little improvement and now I did more or less the job entering on code the following lines:

    sc_pdf_multi_cell(0,5,{products_demo_product_code} ." ". {products_demo_product_desc}."\n".
    {demo_booking_Prospect}."\nData presentazione: ".
    {demo_booking_demo_date}." Ore: ".{demo_booking_demo_hours}."\nLuogo: ".
    {demo_booking_demo_address}."\nNote 1:".
    {products_demo_note}."\nNote 2:".
    {demo_booking_demo_note} ."\n");

    The problem now is how to set left margin to start printing on right place .
    See image attached

    Anyone can help me about the way to set it ??
    Attached Files

    Comment


    • #3
      Check here: http://www.tcpdf.org/examples.php there are examples on multi column printing.
      Then replace $this->xxx functions in the code with sc_pdf_xxx functions. Or you can choose to use $this->pdf (should also work).

      Comment


      • #4
        Thanks rr,
        more or less I'm almost at a good point
        This is what I did to obtain the result on image attached.

        Body:
        sc_pdf_set_left_margin(25);
        sc_pdf_multi_cell(0,5,{demo_booking_Prospect}."\n" .
        "Data presentazione: ". {demo_booking_demo_date}." Ore: ".{demo_booking_demo_hours} ."\n\n" .
        {products_demo_product_code}." ". {products_demo_product_desc} ."\nNote 1:".
        {products_demo_note}."\nNote 2:".
        {demo_booking_demo_note} ."\n");

        The problem I have now is on the header
        Do you know why the last line is not printed ? Seems that Header do not like multi cell but in my ignorance do not make sense.


        Header:
        sc_pdf_print($cell_demo_booking_demo_bookingID);
        sc_pdf_print($cell_demo_booking_SalesmanID);
        sc_pdf_print($cell_demo_booking_CustomerID);
        sc_pdf_print($cell_customers_CompanyName);
        sc_pdf_print($cell_customers_Address);
        sc_pdf_print($cell_customers_PostalCode);
        sc_pdf_print($cell_customers_City);
        sc_pdf_print($cell_customers_Region);
        sc_pdf_print($cell_customers_Country);
        sc_pdf_print($cell_customers_VatCode);
        sc_pdf_print($cell_customers_CodFisc);
        sc_pdf_print($Flag_Rich_Demo);
        sc_pdf_multi_cell(0,5,{demo_booking_demo_address}. "\n");

        aaa.jpg

        Comment


        • #5
          See: http://www.tcpdf.org/doc/code/classTCPDF.html cIick open MultiCell . I guess that you have to enlarge the height... I havent tried this but I did do some customised pdf work...
          For tc_pdf you need to test and try sometimes to get it right...
          TCPDF::MultiCell ( $w,
          $h,
          $txt,
          $border = 0,
          $align = 'J',
          $fill = false,
          $ln = 1,
          $x = '',
          $y = '',
          $reseth = true,
          $stretch = 0,
          $ishtml = false,
          $autopadding = true,
          $maxh = 0,
          $valign = 'T',
          $fitcell = false
          )

          This method allows printing text with line breaks. They can be automatic (as soon as the text reaches the right border of the cell) or explicit (via the
          character). As many cells as necessary are output, one below the other.
          Text can be aligned, centered or justified. The cell block can be framed and the background painted.
          Parameters
          $w (float) Width of cells. If 0, they extend up to the right margin of the page.
          $h (float) Cell minimum height. The cell extends automatically if needed.
          $txt (string) String to print
          $border (mixed) Indicates if borders must be drawn around the cell. The value can be a number:
          • 0: no border (default)
          • 1: frame
          or a string containing some or all of the following characters (in any order):
          • L: left
          • T: top
          • R: right
          • B: bottom
          or an array of line styles for each border group - for example: array('LTRB' => array('width' => 2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0)))
          $align (string) Allows to center or align the text. Possible values are:
          • L or empty string: left align
          • C: center
          • R: right align
          • J: justification (default value when $ishtml=false)
          $fill (boolean) Indicates if the cell background must be painted (true) or transparent (false).
          $ln (int) Indicates where the current position should go after the call. Possible values are:
          • 0: to the right
          • 1: to the beginning of the next line [DEFAULT]
          • 2: below
          $x (float) x position in user units
          $y (float) y position in user units
          $reseth (boolean) if true reset the last cell height (default true).
          $stretch (int) font stretch mode:
          • 0 = disabled
          • 1 = horizontal scaling only if text is larger than cell width
          • 2 = forced horizontal scaling to fit cell width
          • 3 = character spacing only if text is larger than cell width
          • 4 = forced character spacing to fit cell width
          General font stretching and scaling values will be preserved when possible.
          $ishtml (boolean) INTERNAL USE ONLY set to true if $txt is HTML content (default = false). Never set this parameter to true, use instead writeHTMLCell() or writeHTML() methods.
          $autopadding (boolean) if true, uses internal padding and automatically adjust it to account for line width.
          $maxh (float) maximum height. It should be >= $h and less then remaining space to the bottom of the page, or 0 for disable this feature. This feature works only when $ishtml=false.
          $valign (string) Vertical alignment of text (requires $maxh = $h > 0). Possible values are:
          • T: TOP
          • M: middle
          • B: bottom
          . This feature works only when $ishtml=false and the cell must fit in a single page.
          $fitcell (boolean) if true attempt to fit all the text within the cell by reducing the font size (do not work in HTML mode). $maxh must be greater than 0 and equal to $h.
          Returns int Return the number of cells or 1 for html mode. Since 1.3 See Also SetFont(), SetDrawColor(), SetFillColor(), SetTextColor(), SetLineWidth(), Cell(), Write(), SetAutoPageBreak()


          Comment


          • #6
            I modified a bit the code as follow
            The header is standar as SC does while the body I did a customization in order to have single record fields split into several lines.
            Now I got the problem that the next record page is correct about header but about the body, on second page (2nd record) , it starts NOT correctly as expected.
            I got a A4 sheet . Need I to add within code something about page lenght or something similar ??
            I added for testing sc_pdf_set_top_margin(113) as the setting heigh of PDF Report but it makes a..mess.
            Thanks

            BODY CODE
            SC created Code commented
            /*------------------ Page 1 -----------------
            sc_pdf_print($cell_products_demo_product_code);
            sc_pdf_print($cell_products_demo_product_desc);
            sc_pdf_print($cell_demo_booking_Prospect);
            sc_pdf_print($cell_demo_booking_demo_date);
            sc_pdf_print($cell_demo_booking_demo_hours);
            sc_pdf_print($cell_demo_booking_product_demoID);
            sc_pdf_print($cell_products_demo_note);
            sc_pdf_print($cell_demo_booking_demo_note);
            -------------------------------------------*/
            Custom code

            sc_pdf_set_left_margin(25);
            sc_pdf_multi_cell(0,5,{demo_booking_Prospect}."\n" .
            "Data presentazione: ". {demo_booking_demo_date}." Ore: ".{demo_booking_demo_hours} ."\n\n" .
            {products_demo_product_code}." ". {products_demo_product_desc} ."\nNote 1:".
            {products_demo_note}."\nNote 2:".
            {demo_booking_demo_note} ."\n");

            Attached Files
            Last edited by giovannino; 03-31-2016, 08:08 AM.

            Comment

            Working...
            X