PDF/Print with nested tables

PDF/Print with nested tables

wilfredcomwilfredcom Posts: 10Questions: 1Answers: 0

Hello I'm using the feature of export PDF and print button, this works weel since it produce the PDF or launch the print option BUT nested tables doesn't show the well formated structure as you can see in the image.

In the HTML all works without problems

There are the code:

<table class="ui very basic table " id="tableInforme">
    <thead class="hidden">
      <tr><td></td></tr>
    </thead>
    <tr>
      <td>
        <table class="ui selectable single line table">
          <tr>
            <td class="five wide">
              <div class="ui small header">Nombre del estudiante:</div>
            </td>
            <td class="eleven wide">
              aaa aaaa            </td>
          </tr>
          <tr>
            <td>
              <div class="ui small header">Documento de identidad:</div>
            </td>
            <td>
              CC 6789            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>

<script>
$('#tableInforme').DataTable({
      dom: 'tB',
      scrollY: true,
      scrollX: false,
      "paging":   false,
      "ordering": false,
      "info":     false,
      buttons: [
        {
          extend: 'pdf',
          text: 'Exportar a PDF',
          className: 'exportPDF'
        },
        {
          extend: 'print',
          text: 'Imprimir',
          className: 'exportPrint'
        },
      ]
    });
</script>

Replies

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Hi @wilfredcom ,

    This thread might help, it's asking the same thing.

    Cheers,

    Colin

  • wilfredcomwilfredcom Posts: 10Questions: 1Answers: 0

    Thanks a lot.
    It worked very well with PRINT button, but doesn't with PDF.
    Any advise when I can found help?

    Cheers and thanks again.

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Odd, would've thought they would behave the same. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • wilfredcomwilfredcom Posts: 10Questions: 1Answers: 0

    .

  • wilfredcomwilfredcom Posts: 10Questions: 1Answers: 0

    @colin thanks for the help, I tryed to made this comment before but the system says it'll be reviewed.

  • wilfredcomwilfredcom Posts: 10Questions: 1Answers: 0

    In http://live.datatables.net/vupatuya/1/edit you can find an example of what i'm doing and how this didn't work.

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    That looks OK to me. But that said, you're using colspan in the table body, this isn't supported - see here.

    Cheers,

    Colin

  • wilfredcomwilfredcom Posts: 10Questions: 1Answers: 0

    Thanks @colin
    If we omit the colspan and look again even with more columns and rows you can see it's like the structure (cols and rows) isn't respected, in the screen shoot of my PDF export you can see by example in the table 1 the 4 column titles are ok but column 4 in row 1 and table 1 this content is "continued" in the row 2 moving all the another columns and disorganize the whole structure.
    In the table 2 the problem comes even to the titles, you can see the content of the col 1 row 1 table 2 is in the same line with the table titles.

  • wilfredcomwilfredcom Posts: 10Questions: 1Answers: 0

    This one example can be founded in http://live.datatables.net/vupatuya/4/edit

  • allanallan Posts: 61,710Questions: 1Answers: 10,103 Site admin

    Thanks for the example - I'm afraid you are pushing the Buttons PDF export beyond what it was designed for there. Specifically it doesn't handle the inner tables you have in the header. It just grabs the raw text from those outer cells which is why it looks rubbish!

    If you need the inner tables in your PDF export, you'd need to make use of pdfmake directly to create the PDF file.

    Allan

  • ujwalujwal Posts: 1Questions: 0Answers: 0

    column which u want print/pdf/excel arrange it into one row . netsed column also same row but column visiblity false

This discussion has been closed.