Closed vanboom closed 8 years ago
@vanboom : Thanks for the feedback!
Currently, there is no easy solution for putting more than a single icon into a table cell. This may be due to a deficiency in Prawn::Table
. For example, is it possible to place 2 or more images into a single table cell? Or switch fonts within a single cell? Honestly, I don't use Prawn::Table
very often so I'll have to look into it and figure out a solution.
In the meantime, it is somewhat possible to achieve a similar effect using subtables:
icons = [
[
pdf.table_icon('fa-user', align: :center),
"SubCell 1",
"SubCell 2",
pdf.table_icon('fa-birthday-cake', align: :center)
]
]
data = [
['Cell 1', 'Cell 2'],
[icons, 'Cell 4']
]
pdf.table(data)
Be warned that it is very easy to raise a Prawn::Errors::CannotFit
exception using the above code (also I think the above code looks terrible).
Anyways, I'll take a look in the next couple of days and see if I can come up with a straightforward solution.
@vanboom : If inline-formatting for the table_icon
method was to be implemented, would your use-case be satisfied?
For example:
data = [
['1', '2'],
[pdf.table_icon('<icon>fa-user</icon> Any Text Here... <icon>fa-cloud</icon>', inline_format: true), '4']
]
pdf.table(data)
Currently the above code will raise an exception, but I believe it's fairly straightforward to implement.
There are caveats to inline-formatting though - you generally give up fine grained control over the location of the icon (valign, etc.) as icons are unable to move independently of the text block.
I went ahead and implemented the functionality above. This should allow for a straightforward mechanism to create multiple icons within a table cell. Please update to v0.7.0
to gain this functionality.
You can see an example of the syntax here.
Is it possible to place two icons in the same table cell?
Wow - what a great gem! Thanks so much!