Giter Site home page Giter Site logo

Comments (15)

yelouafi avatar yelouafi commented on June 15, 2024 8

Needed that for my app so i added some lines of code to tableProcessor.js;
You use it by adding another function in the layout definition

var layout = { 
    hLineWidth: function(i, node) { ... }, 
    vLineWidth: function(i, node) { ... }, 
    hLineColor: function(i, node) { ... }, 
    vLineColor: function(i, node) { ... }, 
    //you just return null for the rest
    fillColor: function(row, col, node) { return row > 0 && row % 2 ? 'yellow' : null; }
} 

here is a plunker to test

Not sure if that will fit well the rest o library but i tested it and it works well (even against variable border sizes)

from pdfmake.

onbermejo avatar onbermejo commented on June 15, 2024 1

Nice work yelouafi.
Is it possible to assign a cell color inside the code? For example:

[{ text: 'Cell text', style: 'headerTable', colSpan:2, fillColor:'red'},{}]

from pdfmake.

yelouafi avatar yelouafi commented on June 15, 2024 1

Sorry I was fixing some issues and did some branching reset
Plunker should be working fine now
BTW i changed the usage to a more natural fillColor style property as @onbermejo commented;

[{ text: ...., fillColor: 'yellow'}]

And since it's style property you can also use the library styling capabilities (style dictionaries, style overrides)

var docDef = {
    .....    
    [{ text: ....,  style: 'myCell'}]
   .....
   styles: {
     myCell: { fillColor: 'yellow' }
   }

from pdfmake.

ironmanBlue14 avatar ironmanBlue14 commented on June 15, 2024

Hi, I try to use this library and it's very simple and fun.
But I need to set a style with background color to a table cell..Is it possible?

thanks

from pdfmake.

bpampuch avatar bpampuch commented on June 15, 2024

Not yet

Sorry, I've been very busy during last 3 weeks, I'll get back to pdfmake next week.

from pdfmake.

ironmanBlue14 avatar ironmanBlue14 commented on June 15, 2024

Ok, thanks for your answer!

from pdfmake.

ironmanBlue14 avatar ironmanBlue14 commented on June 15, 2024

Hi, sorry, but I need to use this feature.
When do you think will be implemented?
I need this information because I may find another library...

Thanks

from pdfmake.

BobbieBarker avatar BobbieBarker commented on June 15, 2024

I would like to add that I could really use this feature as well.

from pdfmake.

onbermejo avatar onbermejo commented on June 15, 2024

Yes, It could be really useful. And It would be great not only to a cell, also to a complete row. Thanks

from pdfmake.

martingrasso avatar martingrasso commented on June 15, 2024

Hmm, I'm not seeing this working in Chrome on plunker. Is this this working?

from pdfmake.

onbermejo avatar onbermejo commented on June 15, 2024

It is working very well!
Thank you @yelouafi

@yelouafi :Before I implement it on my production server, I would like to know if this new library is the same as the original, only with the change of the fillColor? I have been comparing them and there are several changes.

@bpampuch : Are you going to implement this changes to your original file?

It would be great not to divide the project,

Thanks.

from pdfmake.

yelouafi avatar yelouafi commented on June 15, 2024

@onbermejo the only changes are (the master branch includes also the latest builds)

  • modified sources files (4): docMeasure, elementWriter, pageElementWriter and tableProcessor
  • files in the build directory, those are necessary if you want to use the library on the browser (you should avoid the minified version for now until issues #18 and #60 are fixed)

you can also checkout the tableCellFillColor and run your own builds locally

BTW you may also find it useful to merge the textDecorator

And just a last EDIT: i don't intend to create a new library from this fork; all those features are intended to enhance the main library (which i find awesome to have in the node.js archipel).

as for the integration into the main library i already made this pull requests #82 and #79;

from pdfmake.

martingrasso avatar martingrasso commented on June 15, 2024

Thanks, yelouafi.

I just wasn't sure if I was doing something incorrect at the time or using an unsupported

I appreciate your efforts on this project. You are doing some pretty cool things.

from pdfmake.

bpampuch avatar bpampuch commented on June 15, 2024

PR has been merged

from pdfmake.

JulianHidalgo avatar JulianHidalgo commented on June 15, 2024

Hi
I'd like to create a table with alternating background colors for each row. yelouafi's original approach with the table layout would have worked for me, but I see the fillColor property is now a part of the cell's style itself, which is also practical, but not so handy for what I want. Is there any way to do this without setting a style for each row on my code? Thanks!

from pdfmake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.