Skip to content

PrintFormat

Print format configuration DocType.

Stores print template configuration for a DocType.
Attributes:
name: Display name for the format
doctype: Target DocType this format applies to
template: Path to Jinja2 template file
is_default: If True, this is the default format for the DocType
css: Optional custom CSS for styling
header_html: Optional custom header HTML
footer_html: Optional custom footer HTML
page_size: Page size for PDF (A4, Letter, etc.)
orientation: Page orientation (portrait, landscape)
Example:
format = PrintFormat(
name="Invoice Pro Forma",
doctype="Invoice",
template="invoice_proforma.html",
)

Source: print_format.py

Field Type Required Description Validators
name str Display name for the print format minLen: 1, maxLen: 255
doctype str Target DocType this format applies to minLen: 1
template str Path to Jinja2 template file (if using file-based templates) -
custom_html None Raw Jinja2/HTML template string (if using DB-based templates) -
is_default bool If True, this is the default format for the DocType -
css None Optional custom CSS for styling -
header_html None Optional custom header HTML -
footer_html None Optional custom footer HTML -
page_size str Page size for PDF (A4, Letter, Legal) pattern: `^(A4
orientation str Page orientation (portrait, landscape) pattern: `^(portrait
Role Create Delete Read Write
All
System Manager
Setting Value
Submittable False
Track Changes True

Controller hooks are implemented in *_controller.py files. Available lifecycle hooks:

  • validate() - Called before save, raise exceptions for validation errors
  • before_insert() - Called before inserting a new document
  • after_insert() - Called after successfully inserting
  • before_save() - Called before saving (insert or update)
  • after_save() - Called after saving
  • before_delete() - Called before deleting
  • after_delete() - Called after deleting