Skip to content
Discussion options

You must be logged in to vote

local_context(textstyle=...) is not supported directly. local_context() accepts graphics-state keyword arguments such as font_family, font_style, font_size_pt, text_color, and fill_color; an unknown textstyle argument raises ValueError: Unsupported setting (API and accepted settings).

TextStyle is mainly used by the HTML/paragraph rendering APIs. For example, it is natively reusable with:

pdf.write_html(html, tag_styles={
    "h1": MyTitle1Style,
    "h2": MyTitle2Style,
})

For normal cell()/multi_cell() calls, you can make a small adapter for the font/color subset:

from fpdf import TextStyle

TITLE_1 = TextStyle(
    font_family="helvetica",
    font_style="B",
    font_size_pt=18,
    c…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jxrossel
Comment options

Answer selected by jxrossel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants