Table tools, pdf: add style? At least bold and italic?

Table tools, pdf: add style? At least bold and italic?

overnoiseovernoise Posts: 1Questions: 0Answers: 0
edited March 2011 in TableTools
Hi, probably I'm missing something.
Datatables saved my life but now I have a really bad problem for me:
I need to export a pdf from a table that has some and text...
Without them the table is pretty illegible...tell me I can do that!! :(

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    It's not something that I've built into the way that TableTools uses the PDF generating library - but it looks from the documentation that it is indeed possible: http://alivepdf.bytearray.org/alivepdf-asdoc/org/alivepdf/fonts/FontFamily.html . Modifying the AS code which builds the PDF should be possible if you fancy giving it a go.

    Allan
  • meishiermeishier Posts: 4Questions: 0Answers: 0
    hi,allan

    but in the download package, i can not find the copy_cvs_xls_pdf.swf's Flex project source code. After modifying the ZeroClipboardPdf.as code, is there any way to recompile it and output a new copy_cvs_xls_pdf.swf?
    For my question, i want to export a pdf with japanese font supported. any suggestion?

    thank you for your good work!
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    The top line in the ZeroClipboardPdf.as file gives the mxmlc command needed to compile the AS file to SWF:

    [code]
    /* Compile using: mxmlc --target-player=10.0.0 -static-link-runtime-shared-libraries=true -library-path+=lib ZeroClipboardPdf.as */
    [/code]
    You'll need the Flex 4 SDK to build the SWF - which you can get free from the Adobe open source pages.

    Allan
  • meishiermeishier Posts: 4Questions: 0Answers: 0
    Thank you allan. I made it. Now I can export a Japense supported pdf by using UnicodePDF class.
    However the column name with
    tag in html can not not be rendered correctly in PDF. What shall i do with this?


    for example
    now: AA
    BB in html, AABB in pdf
    excepted: AA
    BB in html, AA\nBB in PDF

    Thank you!
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I wonder if I should just use UnicodePDF() as the default... I don't see any downside - have you encountered any?

    For the
    issue, I think you'll need to add in a 'replace'. str.replace('
    ','\n'); or something like that should do it.

    Allan
  • meishiermeishier Posts: 4Questions: 0Answers: 0
    edited April 2011
    yes,
    1.modify PDF.as,
    - var txt2:String = findAndReplace(')','\\)',findAndReplace('(','\\(',findAndReplace('\\','\\\\',text)));
    + var txt2:String = escapeIt(text);
  • complainingestcomplainingest Posts: 1Questions: 0Answers: 0
    I'm attempting to preserve some formatting in the generated PDF as well - at least some
    s - but I'm such a novice, I can't seem to get anything to work.

    First of all, where in ZeroClipboardPdf.as would I add the recommended str.replace('
    ','\n');?

    And I've tried following instructions on recompiling the file, but I keep getting this error: "A file found in a source-path 'ZeroClipboardPdf' must have the same name as the class definition inside the file 'ZeroClipboard'." I was able to compile the ZeroClipboard.as file to a .swf, so it seems there is something wrong with the ZeroClipboardPdf.as file?

    -library-path+=lib - is this the path to the lib inside of the as3 directory (tabletools), or the lib inside of the flex_sdk directory?
  • DarryljackmanDarryljackman Posts: 1Questions: 0Answers: 0
    I can't believe with how elaborate all the datatables and tabletools stuff is, yet to have to freaking recomplie .as files to change the font!! WT!? I downloaded the sdk, then finally JRE when I found that out. Then apparently added the system variables for java, and all to end up with some stupid non sensible error about file can't be inline with itself or something, an error that google don't help much with. I can't believe the hours spent TRYING TO CHANGE ONE FONT SIZE! Who would ever program a font size (especially when the default is huge to begin with) to be hard coded? It should have been in a CSS file, built in option, or even easier for flash, a XML file. What developer would not want control the visual output???

    Also, I have some tables that have images in them (checkmark by certain entries in the table. Datatables picks them up and can even sort by them which I didn't expect which is great, but again tabletools comes along and do not display them on the PDF (the checkmarks being the important part of the PDF.

    Another issue was when using the print button, there is no inherent way to put a title on top or the printout. I don't know what other people use tabletools for, but I imagine it would be mostly report related, which by definition has data in a table, and a title on top. I have the title on the page already, but because table tools ONLY shows the table itself when the print button is pressed. I made a crud workaround where I put hidden fields on the page, used jquery to get the values, and was able to re display them on the top of the print preview, again, very cumbersome, shotty output.

    Datatables is PERFECT, can't find one thing that could be changed. Tabletools however is great in concept, but so pooorly done, that i cant see anyone using this with full satisfaction, and anyone who is using it, is probably putting up with the limitations because the are few other altnatives, but it is so inefficient, that the idea it is supposed to help cut down time and effort for developers is silly. The only part of my fairly complicated web app that I can't easily control is all the tabletools stuff, so that leaves dropping tabletools and adopting a more user friendly, php PDF solution which are majorly customizable, readily available, and clear documentation, but does unfortunately take some development, however i feel it would have been less time overall considering all the time spent implementing tabletools just to find all the limitations, and hope no one else wasted as much time on tabletools as I did, for such mediocre and clumsy output,
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    I completely acknowledge that TableTools' PDF controls are extremely limited - I'm sorry that you've had a hard time configuring it as you wish. Its a hard balance to get right to keep the code size small, but the configurablity high, and I'm not happy with the results at the moment. The problem is getting the time to spend developing a better solution! Certainly if anyone has a suggestion for a different PDF generator library for TableTools, I'd be very interested, and I thin it needs to have its own API more exposed for customisation.

    Allan
  • vinitsharmavinitsharma Posts: 23Questions: 0Answers: 0
    I would like to ask something over here. If I want to set or adjust the width of the columns in the exported files, either pdf or excel, can I make this possible or not? I want to set the width of the various columns in the exported pdf and excel so can I make this possible or not? Also what other formatting options i can apply on the exported pdf or excel files.?Please tell.
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    @vinitsharma Please don't cross post the same question. I try my best to answer as many as possible and with the same question cropping up multiple times it makes it very hard: http://datatables.net/forums/discussion/327/tabletools-v1.0.2-save-as-excel-csv-copy-and-print#Item_133
  • vinitsharmavinitsharma Posts: 23Questions: 0Answers: 0
    @Allan, i apologize for posting same question at multiple places. But can't I adjust the width somehow by editting the .AS or .SWF or any other file. Like when I used fnCalcColRatios() in the excel output, it simply added the ColumnRatios values in the outputted excel file. If I could use this fnCalcColRatios() in excel output, then also may be my problem may get solved. But isnt there any other way to change the excel output, not more to the extent but atleast for the sake of changing the width of the columns?
  • sayannayassayannayas Posts: 2Questions: 0Answers: 0
    I got it solved using correct flex sdk version,the compilation was failing because of old AlivePDF.swc usage and old sdk version.I have noted down all the steps that i followed during compilation.It may be helpful to somebody,follow this link-http://fundapass.blogspot.in/2012/11/datatables-tabletools-styling.html
  • thewoolleymanthewoolleyman Posts: 1Questions: 0Answers: 0
    Hello,

    Thanks for writing table tools. I've read through the above thread, but I'm still not clear... How can I add a newline to the "sPdfMessage" section, so I can have a multi-line header on my generated PDF?

    Thanks a lot...
    -- Chad
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi Chad,

    Looking at the TableTools code, I don't think it is possible at the moment. The issue is that TableTools is using \n as a field separator, so if you add \n for your new line, it will treat the next line as a new field. A bit naff that :-(.

    It would need a change to both he TableTools JS and AS3 scripts. Something I'll consider for v3, although pull requests before then are welcome :-). In the mean time the easiest solution is to modify the AS3 to treat '---' (for example) as a newline in the message string - just to do a replace on it.

    Allan
  • AA23AA23 Posts: 13Questions: 0Answers: 0
    Does anybody got the Button issue resolved in TableTools ????
    I also implemented the same thing but there is no action when i click on the buttons.
    What should I do . Please suggest me something I have got stuck.
  • AA23AA23 Posts: 13Questions: 0Answers: 0
    Please somebody reply .......
    My code is
    $('#table1').dataTable( {
    "bJQueryUI": true,
    /* "sPaginationType": "full_numbers", */
    "bProcessing": true,
    "bServerSide": true,
    "bDestroy": true,
    "bAutoWidth": true,
    "sScrollX": "940px",
    //"sScrollY": "250px",
    "bScrollCollapse": true,
    "aoColumns": [
    null,
    null,
    null,
    null,
    null,
    null,
    { "bSortable": false }
    ] ,
    "sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
    "oTableTools": {
    //"sSwfPath": "/public/swf/ZeroClipboard.swf",
    "sSwfPath": "//swf/copy_csv_xls_pdf.swf",
    "aButtons": [
    "copy",
    "csv",
    "xls",
    {
    //"sExtends": "collection",
    "sExtends": "pdf",
    "sTitle": "Report Name",
    "sPdfMessage": "Summary Info",
    "sPdfOrientation": "landscape",
    //"sSwfPath": "/swf/ZeroClipboard.swf",
    "fnClick": function( nButton, oConfig ) {
    this.fnPrint( true, oConfig );
    },
    "print"
    ]

    },
    "sAjaxSource": url,
    "fnServerData": function ( sSource, aoData, fnCallback ) {
    // Add some extra data to the sender
    //aoData.push();
    $.ajax( {
    "dataType": 'json',
    "type": "POST",
    "url": sSource,
    "data": aoData,
    "success": fnCallback
    } );

    }

    });
  • AA23AA23 Posts: 13Questions: 0Answers: 0
    Please if anybody can help please suggest your review on the above code ...

    The buttons of TableTools are getting displayed but nothing is happening on clicking on them,
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Link to a test case please: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read
This discussion has been closed.