KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

PhantomJs Export column width #3474

Open iWorQ Systems opened this topic on on Mar 3 - 9 comments

iWorQ Systems commented on Mar 3

we are exporting our our tables and data tables to a pdf and the column widths arent staying what they should be from the table.

What do I need to add to a pdf.view.php data table and table to be able to get the columns not to just auto size?

Sebastian Morales commented on Mar 4

Have you tried the following column settings for Table and DataTables:

Table::create(array(
    ...
    "columns"=>array(
        "amount"=>array(
            ...
            "cssStyle"=>"width:200px"
        ),


DataTables::create(array(
    ...
    "columns"=>array(
        "orderNumber"=>array(
            ...
            "width"=>"200px",
        ), 
iWorQ Systems commented on Mar 4

The issue is that we can customly set each columns width and were doing that through the data tables options

'columnDefs' => [
                        [
        "width" => "101.6mm",
        "targets" => 0,
    ],
    [
        "width" => "25.4mm",
        "targets" => 1,
    ],
    [
        "width" => "25.4mm",
        "targets" => 2,
    ]
                    ]
Sebastian Morales commented on Mar 5

I think there are 3 possible solutions:

  1. Set fixed table layout style together with column width:
<style>
  table {
    table-layout: fixed;
    width: 100%;
  } 
  1. Use auto table layout with column min-width:
<style>
    table { table-layout: auto; }
    .col1 { min-width: 100px; }
    .col2 { min-width: 200px; } 
  1. Use <colgroup> tag:
<table style="width: 100%;">
  <colgroup>
    <col style="width: 100px;">
    <col style="width: 50%;">
    <col>
  </colgroup>

The current DataTables version has not supported adding <colgroup> yet, you might have to use an "onReady" event listener javascript function to insert it into your DataTables.

iWorQ Systems commented 7 days ago

thanks the <style> one worked for me

Just had to write a function that would convert my column headers into the appropriate css

if my column was named Big One

the css would be

.header-Big.One { min-width: 200px; }

and that worked like a charm

iWorQ Systems commented 7 days ago

One last question, do you guys have anyway of wrapping the tables to the next page if the columns are too big or too many? meaning if they are about to be cut off they just go to the next page?

our old system does that and we are trying to match it as close as we can.

Sebastian Morales commented 6 days ago

Did you mean putting a page break to a long table at a row's completion, not at the middle of it, and repeat the table header in the next page?

iWorQ Systems commented 6 days ago

yes that is what we mean

iWorQ Systems commented 3 days ago

What I actually mean is with the columns. Our old report PDF builder was able to if the report was too big to be on one page, move the next column to the next Page. it looked something like this.

Sebastian Morales commented 1 day ago

Ah, this is interesting and challenging to split a table by its columns. We must do some research and let you know if there is a possible solution with current PDF rendering engines used by KoolReport.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

DataGrid