TableTools PDF export: Align text left but numbers right

TableTools PDF export: Align text left but numbers right

hkd66hkd66 Posts: 2Questions: 0Answers: 0
edited November 2013 in TableTools
Hi

Within the DataTable on the web page everything is fine: I gave the s with numbers the css class .text-right and they are displayed as numbers should be displayed. :-)

[code]
.text-right {
text-align: right;
}
[/code]

However, in the PDF-output generated by TableTools all columns are aligned left. This makes large numbers together with small numbers in the same column quite unreadable.

Any ideas how to solve this?

Replies

  • hkd66hkd66 Posts: 2Questions: 0Answers: 0
    bump? bump. ;-)
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    edited November 2013
    Sorry no - there are no formatting options available for the PDF export. If you want control over the formatting you'd need to use a server-side script to generate the PDF.

    Allan
  • marcosfonsecamarcosfonseca Posts: 3Questions: 1Answers: 0
    Hi allan, what is the diference of use server-side or normal data?

    I have PHP+MySQL data and i'm printing on datatable. I want to style PDF, so i changed some ActionScript on AlivePDF. But I can't align right per now...Maybe with "datagrid" instead of "grid"...
  • allanallan Posts: 63,679Questions: 1Answers: 10,498 Site admin
    In the case of using a server-side script to generate the PDF, you'd need to write the script since I don't have one available. TableTools is a client-side library.

    Allan
  • jordivela007jordivela007 Posts: 6Questions: 0Answers: 0
    edited December 2013
    I used this in tabletools definition:

    [code]
    {
    "sExtends": "pdf",
    "sButtonText": "PDF",
    "sTitle": "Title",
    "bSelectedOnly": true,
    "bFooter": true,
    "fnCellRender": function ( sValue, iColumn, nTr, iDataIndex ) {
    // Append the text 'TableTools' to column 5
    if ( iColumn === 10 ) {
    var dato = sValue + " €";
    return padspace(dato,9); /* fill with _ to 9 length */
    }
    return sValue;
    },
    "mColumns": [ 1, 2, 9, 10],
    "sToolTip": "Exportar como PDF"
    },
    [/code]

    and the function padspace:

    [code]
    function padspace(n, length) { // fill with _

    n = ("_______________" + n).slice(-length);
    return n;
    }
    [/code]

    and the pdf shows align right:

    [quote]
    _123.45 €
    __23.45 €
    ___3.45 €
    [/quote]
This discussion has been closed.