johnfercher / maroto

A maroto way to create PDFs. Maroto is inspired in Bootstrap and uses gofpdf. Fast and simple.
https://maroto.io
MIT License
2.25k stars 213 forks source link

Support for multiple styles of text in same cell #189

Open mcolburn opened 3 years ago

mcolburn commented 3 years ago

This is a request for information.

The Issue Maroto does not seem to support the mixing of font styles, colors, or font size within the text of a table cell. Formatting can be applied to the text of the cell as a whole, but not to individual parts of the text.

The Solution I would Like I am rewriting from Java to Go a system for static website generation with pdfs. See as an example this pdf generated by my Java software. I need a way to mix colors, font style, and font size for words, phrases, or sentences found in a single line of text in the cell of a (borderless) table. For example, see below:

Screen Shot 2021-11-03 at 1 19 35 PM

Note how part of the text is in red. For the Java system, words, phrases, or sentences can be bold, italic, etc. or a different font size.

My Question Is this possible in Maroto? If not, would you consider a request to add this feature? One way to look at it, is the Text() function would receive a slice of Spans, each with its own formatting, instead of just a text string.

lordofscripts commented 6 months ago

Watching! I need this too! The assumption that a column is of the same style is too simplistic. That worked for the report examples but not in other scenarios.

A column may have several components, one of them being text but that text may be a paragraph. That paragraph may be of a single font, but in many scenarios that paragraph mixes fonts (regular narrative plus inline code) or styles (words or phrases in bold, italic, underline, etc.).

I am writing a Metadata Exporter for the Novelist app and I need to create main sections for Themes, Events, Characters, Locations, Properties, etc. and each of those main sections have tables with tags, references, descriptions with simple formatting (in the form of spans within the text element).

Originally I was directly using go-pdf.FPDFbut it was way too low-level. That's why I switched to Maroto because it does a lot of abstraction.

So, looking forward to this!