[Idea] Partial CSS support for creating .pdf files from within ruby, via hexapdf #425
Replies: 1 comment
|
The style system via I'm not sure whether implementing a CSS parser (or depending on an existing one) is a good idea. With VersaDok and its PDF output I used a simple YAML file (see e.g. https://github.com/gettalong/versadok/blob/master/data/versadok/themes/default.yaml) to pre-define the styling as YAML is mapped to correct Ruby classes which can just be ingested directly by Furthermore, if one was to use this theoretical API, it would just be one piece of the puzzle. Depending on the application using HexaPDF it would need to determine where the CSS files come from and correctly invoke the various API methods for setting the styles. It seems you are describing a layer above HexaPDF that supports authoring documents via some form of input format together with CSS styling. |
Uh oh!
There was an error while loading. Please reload this page.
Hey there everyone and Thomas in particular,
I wrote quite some ruby code with regards to widgets; usually ruby-gtk2 and ruby-gtk3,
but also ruby-libui and jruby-swing, via ruby and ... a lot of HTML/CSS too.
I like CSS in general. Perhaps not 100% of it but the core is quite nice and easy to
use and understand. ruby-gtk3 has partial support for CSS, as has ruby-gtk4.
Would it make sense for hexapdf to also have partial support of CSS?
With that I mean to just support a fairly minimal part of CSS, if it makes sense.
This can use the existing API for the most part and then just provide syntactic
sugar or so. Perhaps ID entries have to be added, to allow for individual #id styling
to.
What would make sense for CSS to support via hexapdf? Well ..
I guess a simple way would be colors.
Example from the hexapdf examples webpage:
And the CSS:
And probably some more rules.
With minimal I mean mostly the core aspects of CSS, nothing fancy like
animations or the likes. Ideally with a focus of what the existing API
supports.
People could style this via an external CSS file too, thus allowing hexapdf
more flexibility "on the fly". Even whole themes could be used and shared.
We could also have dedicated APIs to specify CSS classes such as:
And in CSS:
We could also use the HTML "colors" such as steelblue, crimson, tomato,
forestgreen and what not. I find them often easier to remember, than the
RGB values directly.
Anyway. This here is not a "spend time to support it", but more a question
aka the opinion, whether this would be useful or not to have. API-wise I
often don't know how other people think, because I kind of adjust ruby
on-the-fly to any of my use cases, but different people use ruby differently.
How useful would that be? And, how dynamic can .pdf files become? I haven't
really tried javascript in pdf files yet, but I saw videos of what people did in
minecraft, for instance, as well as in excel sheets, so I am curious how much
could be done with .pdf files in general, but also automatically and programmatically
via ruby here. Thoughts? Opinions?
All reactions