danfickle / openhtmltopdf

An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
https://danfickle.github.io/pdf-templates/index.html
Other
1.93k stars 359 forks source link

Allow custom list-style-type strings for unordered lists #905

Open HelvetiaAppDev opened 1 year ago

HelvetiaAppDev commented 1 year ago

With newer CSS it should be possible to define custom strings as symbols for lists instead of the default bullets: https://drafts.csswg.org/css-lists/#text-markers. Would it be possible to get this to work? Currently only some of the most basic symbols are rendered like bullet, circle, square, decimal, all others I attempted defaulted back to the bullet. In most browsers this css would work:

ul {
  list-style-type: "- ";
}
HelvetiaAppDev commented 1 year ago

found a workaround, but still think the easier style should also be possible.

ul li {
  list-style-type: none; /* deactivate default symbol, custom symbol defined below */
  position: relative; /* needed to make the before rule with absolute work correctly */
}

ul li::before {
  content: '-'; /* custom symbol before each unordered list element */
  position: absolute;
  left: -0.8em; /* left of the list item */
  font-size: 1.1em; /* change size of symbol */
}
nanoamp commented 1 year ago

I've got this working in a fork. Some issues with alignment which mean it's not quite MR-ready, but you're welcome to try it.