Skip to content

Releases: py-pdf/fpdf2

New vector drawing API & SVG embedding

22 Jan 17:42
Compare
Choose a tag to compare

Added

Thanks to @torque for contributing this massive new feature:

  • add fpdf.drawing API for composing paths from an arbitrary sequence of lines and curves.
  • add fpdf.svg.convert_svg_to_drawing function to support converting basic scalable vector graphics (SVG) images to PDF paths.

Fixed

  • will_page_break() & accept_page_break are not invoked anymore during a call to multi_cell(split_only=True)
  • Unicode characters in headings are now properly displayed in the table of content, cf. #320 - thanks @lcomrade

HACKTOBERFEST! Detect oversized images, new methods to draw arcs & regular polygons, improved documentation

16 Nov 14:27
Compare
Choose a tag to compare

Added

Fixed

  • All graphics state manipulations are now possible within a rotation context, thanks to @gmischler
  • The exception making the "x2" template field optional for barcode elements did not work correctly, fixed by @gmischler
  • It is now possible to get back to a previous page to add more content, e.g. with a 2-column layout, thanks to @paulacampigotto

Changed

  • All template elements now have a transparent default background instead of white, thanks to @gmischler
  • To reduce the size of generated PDFs, no SMask entry is inserted for images that are fully opaque
    (= with an alpha channel containing only 0xff characters)
  • The rect, ellipse & circle all have a style parameter in common.
    They now all properly accept a value of "D" and raise a ValueError for invalid values.

Deprecated

  • dashed_line() is now deprecated in favor of set_dash_pattern()

Ensuring support for old field names in `Template.code39` for backward compatibility

03 Oct 10:53
Compare
Choose a tag to compare

FlexTemplate, markdown in multi_cell & bug fixes

02 Oct 12:08
Compare
Choose a tag to compare

Added

  • Template() has gained a more flexible cousin FlexTemplate(), thanks to @gmischler
  • markdown support in multi_cell(), thanks to Yeshi Namkhai
  • base 64 images can now be provided to FPDF.image, thanks to @MWhatsUp
  • documentation on how to generate datamatrix barcodes using the pystrich lib: documentation section,
    thanks to @MWhatsUp
  • write_html: headings (<h1>, <h2>...) relative sizes can now be configured through an optional heading_sizes parameter
  • a subclass of HTML2FPDF can now easily be used by setting FPDF.HTML2FPDF_CLASS,
    cf. documentation

Fixed

  • Template: split_multicell() will not write spurious font data to the target document anymore, thanks to @gmischler
  • Template: rotation now should work correctly in all situations, thanks to @gmischler
  • write_html: headings (<h1>, <h2>...) can now contain non-ASCII characters without triggering a UnicodeEncodeError
  • Template: CSV column types are now safely parsed, thanks to @gmischler
  • cell(..., markdown=True) "leaked" its final style (bold / italics / underline) onto the following cells

Changed

  • write_html: the line height of headings (<h1>, <h2>...) is now properly scaled with its font size
  • some FPDF methods should not be used inside a rotation context, or things can get broken.
    This is now forbidden: an exception is now raised in those cases.

Deprecated

  • Template: code39 barcode input field names changed from x/y/w/h to x1/y1/y2/size

Support for emojis & justified text in templates

01 Sep 13:28
Compare
Choose a tag to compare

Added

  • support for emojis! Me precisely unicode characters above 0xFFFF in general, thanks to @moe-25
  • Template can now insert justified text
  • get_scale_factor utility function to obtain FPDF.k without having to create a document
  • convert_unit utility function to convert a number, x,y point, or list of x,y points from one unit to another unit

Changed

  • fpdf.FPDF() constructor now accepts ints or floats as a unit, and raises a ValueError if an invalid unit is provided.

Fixed

  • Template background property is now properly supported - #203
    ⚠️ Beware that its default value changed from 0 to 0xffffff, as a value of zero would render the background as black.
  • Template.parse_csv: preserving numeric values when using CSV based templates - #205
  • the code snippet to generate Code 39 barcodes in the documentation was missing the start & end * characters.
    This has been fixed, and a warning is now triggered by the FPDF.code39 method when those characters are missing.

Fixed

  • Detect missing uni=True when loading cached fonts (page numbering was missing digits)

FPDF.circle, support for named HTML colors & repeating table headers on each page

29 Jun 04:51
Compare
Choose a tag to compare

Added

  • disable font caching when fpdf.FPDF constructor invoked with font_cache_dir=None, thanks to @moe-25 !
  • FPDF.circle: new method added, thanks to @viraj-shah18 !
  • HTMLMixin / HTML2FPDF: support setting HTML font colors by name and short hex codes
  • FPDF.will_page_break
    utility method to let users know in advance when adding an elemnt will trigger a page break.
    This can be useful to repeat table headers on each page for exemple,
    cf. documentation on Tables.
  • FPDF.set_link now support a new optional x parameter to set the horizontal position after following the link

Fixed

  • fixed a bug when fpdf.Template was used to render QRCodes, due to a forced conversion to string (#175)

Bugfixes related to page breaks & unicode fonts

12 Jun 10:48
3354afb
Compare
Choose a tag to compare

Fixed

  • erroneous page breaks occured for full-width / full-height images
  • rendering issue of non-ASCII characaters with unicode fonts

JPEG storage improvements, basic Markdown styling & presentation transitions

12 Jun 07:58
Compare
Choose a tag to compare

Changed

  • now fpdf2 uses the newly supported DCTDecode image filter for JPEG images,
    instead of FlateDecode before, in order to improve the compression ratio without any image quality loss.
    On test images, this reduced the size of embeded JPEG images by 90%.
  • FPDF.cell: the w (width) parameter becomes optional, with a default value of None, meaning to generate a cell with the size of the text content provided
  • the h (height) parameter of the cell, multi_cell & write methods gets a default value change, None, meaning to use the current font size
  • removed the useless w & h parameters of the FPDF.text_annotation() method

Added

  • new FPDF.add_action() method, documented in the Annotations section
  • FPDF.cell: new optional markdown=True parameter that enables basic Markdown-like styling: **bold**, __italics__, --underlined--
  • FPDF.cell: new optional boolean center parameter that positions the cell horizontally
  • FPDF.set_link: new optional zoom parameter that sets the zoom level after following the link.
    Currently ignored by Sumatra PDF Reader, but observed by Adobe Acrobat reader.
  • HTMLMixin / HTML2FPDF: now support align="justify"
  • new method FPDF.image_filter to control the image filters used for images
  • FPDF.add_page: new optional duration & transition parameters
    used for presentations (documentation page)
  • extra documentation on how to configure different page formats for specific pages
  • support for Code 39 barcodes in fpdf.template, using type="C39"

Fixed

  • avoid an Undefined font error when using write_html with unicode bold or italics fonts

Deprecated

  • the FPDF.set_doc_option() method is deprecated in favour of just setting the core_fonts_encoding property
    on an instance of FPDF
  • the fpdf.SYSTEM_TTFONTS configurable module constant is now ignored

Minor bug fix

03 Jun 12:28
c43b400
Compare
Choose a tag to compare

Fixed

  • a bug in the deprecation module that prevented to configure fpdf2 constants at the module level

Minor bug fix

30 Apr 16:49
Compare
Choose a tag to compare

Fixed

  • a "fake duplicates" bug when a Pillow.Image.Image was passed to FPDF.image