Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug exporting invisible column to PDF #19

Open
ghost opened this issue Jan 22, 2013 · 5 comments
Open

Bug exporting invisible column to PDF #19

ghost opened this issue Jan 22, 2013 · 5 comments

Comments

@ghost
Copy link

ghost commented Jan 22, 2013

I found a bug where a column with property "bVisible":false is not properly exported to PDF. I have written a sample HTML page, see https://gist.github.com/4599023. Unfortunately you have to run the HTML page from a local webserver because of Flash security restrictions. (It seams the .swf must be served from the same webserver as the HTML file, opening the file with the browser wan't work. I also wrote a jsFiddle with the same problem, perhaps because of the iframe).

The example contains a table with 4 columns, the 3rd column is hidden with "bVisible":false. I would like export all 4 columns, TableTools has been configured with:

"aButtons": [
    {
        "sExtends": "pdf",
        "mColumns": [0, 1, 2, 3],
        "sPdfOrientation": "landscape"
     }
]

The exported PDF has the 4th column merged into the 3rd.

@rgavrilov
Copy link

I'm getting the same behavior. Apparently bug is caused by fnCalcColRatios function, which calculates invisible column width as 0:

iWidth = aoCols[i].nTh.offsetWidth;

Not sure what the good fix would be though, to get proper width we need to render the column, i.e. make it visible.

@DataTables
Copy link
Collaborator

Hmmm - tricky one. Note sure what the correct thing to do is either. Possibly calculate the widths based on the content of the headers (strlen)... What I really would like is for the PDF generator to figure it out, but it doesn't seem to work that way.

@afshinm
Copy link

afshinm commented Oct 19, 2014

Any update on this?

@DataTables
Copy link
Collaborator

Sorry no. I've not had time to work on it yet.

@EverpathDano
Copy link

A hack, super easy, super fast, "at least it looks better than terrible" workaround until someone figures out something better:

iWidth = aoCols[i].nTh.offsetWidth;
if (!iWidth && typeof iDTTTDefaultHiddenColumnWidth !== 'undefined') {
    iWidth = iDTTTDefaultHiddenColumnWidth;
}

then we set the variable in the global scope to have a reasonable default (we have one table per page, we tune to that specific table). Even simpler could be iWidth = aoCols[i].nTh.offsetWidth || 200;.

I know, I know, it's hideous and horrible, I'm not suggesting this as a change to the mainline. It has the advantage of getting us up and running again without rolling our own PDF generator, I figured I'd pass it along to other desperate coders. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants