pypi xhtml2pdf 0.2.29
v0.2.29

one hour ago

๐ŸŽ‰ New

  • Page-margin boxes: @page { @top-center { content: ... } } and the
    other fifteen boxes of CSS Paged Media write headers and footers in the
    page's margin, with counter(page), counter(pages) in any counter
    style, and their own font, colour, alignment, background, border, padding
    and opacity -- no static @frame or <pdf:pagenumber> needed.
  • @page :first builds on its @page and is used for the first page,
    so @page :first { @top-center { content: none } } leaves the cover
    without a header.
  • string-set and string(): h1 { string-set: chapter content() }
    with @top-left { content: string(chapter) } is a running header, with
    the first, start, last and first-except choices.
  • text-decoration: overline, alone or with underline and
    line-through.
  • border-style: groove, ridge, inset and outset are drawn in
    two shades of the border colour, as Chrome draws them, on blocks,
    paragraphs, tables and table cells. They used to come out solid.
  • opacity. A block, a table, a flex container or item, an
    inline-block, a positioned box or an image is painted with what is in it
    as one PDF transparency group, so overlapping parts do not show through
    each other, and links inside keep working. An inline element fades its
    text, background and images.
  • list-style-type: circle draws a hollow ring, the default of a list
    inside a list. It used to draw the same filled bullet as disc.

๐Ÿ’ช๐Ÿผ Improvements

  • Text sits in its line as a browser puts it: the leading is shared above
    and below the text, as CSS does, rather than left below it. A paragraph
    takes the same height as before, and its text is drawn lower inside it,
    by about 0.29 em at the default line-height: 150% -- 2.2 pt at 7.5 pt.
    Compared with Chrome on the 105 fixtures of make test-browser, 66 come
    closer and the average SSIM goes from 0.900 to 0.907. A document laid out
    to the point over a background or a form should be checked.
  • line-height is inherited as CSS says. A percentage or an em
    length is worked out on the element that declares it and its descendants
    take that length, so body { line-height: 150% } gives a heading the
    body's leading, as a browser does, rather than 150% of the heading's own
    size; a number such as 1.5 still follows each element's size. The
    default is now the number 1.5, which lays out exactly as the
    150% it replaces did.
  • A list (ul, ol, dl) has an em of space above and below it, as
    in a browser, and a list inside a list has none; the last item's bottom
    margin collapses into the list's. Lists used to have no vertical margin.
    ul, ol, dl { margin-top: 0; margin-bottom: 0 } keeps the old spacing.

๐Ÿ› Bug-Fixes

  • An @page bleed that is not a length, such as bleed: wide, is
    reported once as the page's bleed, where getSize used to report "Not a
    float" in its own words and the bleed's warning only came for a negative
    value.
  • A table row too tall for any page that a rowspan crosses no longer
    stops the conversion with LayoutError: ... too large on page. Such a
    row cannot be cut, nor can the table between the rows the span joins, so
    those rows are shrunk to fit the page, with a warning naming them; the
    rest of the table goes on as before.
  • A box whose content fits at the foot of a page, with no room for the
    bottom padding under it, no longer leaves a slice of empty box -- its
    padding, background and border -- at the top of the next page. The cut is
    made where the bottom fits too, so the last line goes on with it, or the
    box goes on whole, as in a browser.
  • A forced page break no longer leaves an empty page:
    page-break-before: always on the first element used to make page one
    blank, and page-break-after on one block with page-break-before on
    the next made an empty page between them. A break where nothing is on the
    page yet does nothing, as in a browser; <pdf:nextpage/> still always
    starts a page, and left/right still add the page their parity
    needs.
  • A long table inside a block with a background, padding or border runs on
    across pages again, rather than being shrunk to one page or raising
    LayoutError: Splitting error (:issue:854).
  • A table in a flex item lays its columns out by their content, as a
    browser does, instead of in equal shares of the item. The equal shares
    were narrower than a column's content, so a long table's cells wrapped
    once its numbers grew, and each page held fewer rows than the last.
  • An lta signature without validation_context.trust_roots is
    refused with a ValueError, where pyHanko quietly fell back to the
    operating system's trust list, which it deprecates. extra_trust_roots
    is added to trust_roots instead of being passed on as the deprecated
    key.
  • line-height: 2 and the other whole numbers from 1 to 7 multiply the
    font size; they were read as the sizes of HTML's <font size>, so
    line-height: 2 gave 0.75em.
  • HttpConfig(timeout=30) keeps the timeout it is given; the default of
    5 seconds only fills in a missing one.

๐Ÿงน Cleanup

  • The signing tests are skipped when pyHanko is not installed, so a plain
    pytest run, as Debian's autopkgtest does, no longer stops at
    collection.
  • The test workflow runs on Ubuntu 26.04: testrender reads ImageMagick
    7's compare output, and the 3.13 and 3.14 jobs install libxml2-dev
    (:pr:856).
  • Tests for HttpConfig (:pr:855).

| Thanks to the following people on GitHub for contributing to this release:
| gaborbernat and arifahmedozturk

Don't miss a new xhtml2pdf release

NewReleases is sending notifications on new releases.