gws.lib.htmlx

Source code: gws.lib.htmlx

Package Contents

gws.lib.htmlx.escape(s: str, quote=True) str

Escapes a string for use in HTML.

gws.lib.htmlx.render_to_pdf(html: str, out_path: str, page_size: gws.UomSize = None, page_margin: gws.UomExtent = None) str

Renders an HTML string to a PDF file.

Parameters:
  • html – The HTML content to be converted into a PDF.

  • out_path – The output file path for the generated PDF.

  • page_size – The size of the page in user-defined units. Defaults to None.

  • page_margin – The margins of the page in user-defined units. Defaults to None.

Returns:

The output file path of the generated PDF.

gws.lib.htmlx.render_to_png(html: str, out_path: str, page_size: gws.UomSize = None, page_margin: list[int] = None) str

Renders an HTML string to a PNG image.

Parameters:
  • html – The HTML content to be converted into an image.

  • out_path – The output file path for the generated PNG.

  • page_size – The size of the image in user-defined units. Defaults to None.

  • page_margin – The margins of the image in pixels (top, right, bottom, left). Defaults to None.

Returns:

The output file path of the generated PNG.