Add A4 carrier print mode (paper=a4) and document it in README + Swagger
- packing_list renders A5 content into top region of an A4 portrait page when paper=a4, so A5 paper loaded horizontally in an A4 tray prints upright - run.generate/print_document/print_api thread the optional paper param through - README: new Print Service section with A4 carrier usage + curl example - Swagger: POST /api/print description documents the A4 carrier mode
This commit is contained in:
@@ -124,10 +124,18 @@ def styles() -> list[dict]:
|
||||
]
|
||||
|
||||
|
||||
def document_properties() -> dict:
|
||||
def document_properties(paper: str = "a5") -> dict:
|
||||
# 边距按 pt 给出(ReportBro 不换算 margin;pageFormat=A5 自动换算页面尺寸为 pt)。
|
||||
# A4 承载模式:物理页面仍是 A4 纵向(210x297mm),但内容按 A5 横向(210x148mm)设计、
|
||||
# 自然落在页面顶部 148mm 区域。配合打印机把 A5 纸横向装载进 A4 纸盒,发送 A4 指令即可在
|
||||
# 横向 A5 纸上正常出纸,省去反复调整不同幅面纸盒卡扣的过程。
|
||||
# 因 A5 横向与 A4 纵向宽度同为 210mm,元素 x/宽度完全不变,仅画面高度由 148→297mm。
|
||||
if paper == "a4":
|
||||
fmt, orient = "A4", "portrait"
|
||||
else:
|
||||
fmt, orient = "A5", "landscape"
|
||||
return {
|
||||
"pageFormat": "A5", "orientation": "landscape",
|
||||
"pageFormat": fmt, "orientation": orient,
|
||||
"marginLeft": mm(MARGIN_L), "marginRight": mm(MARGIN_R),
|
||||
"marginTop": mm(10), "marginBottom": mm(10),
|
||||
"headerDisplay": "never", "headerSize": 0,
|
||||
@@ -324,11 +332,14 @@ def build_doc_elements(context: dict[str, Any]) -> list[dict]:
|
||||
return els
|
||||
|
||||
|
||||
def build_report_definition(context: dict[str, Any]) -> dict:
|
||||
"""组装完整 report_definition(运行时调用,按数据动态布局)。"""
|
||||
def build_report_definition(context: dict[str, Any], paper: str = "a5") -> dict:
|
||||
"""组装完整 report_definition(运行时调用,按数据动态布局)。
|
||||
|
||||
:param paper: "a5"(默认,A5 横向直打)或 "a4"(A4 纵向承载模式)。
|
||||
"""
|
||||
return {
|
||||
"version": 6,
|
||||
"documentProperties": document_properties(),
|
||||
"documentProperties": document_properties(paper),
|
||||
"parameters": parameters(),
|
||||
"styles": styles(),
|
||||
"docElements": build_doc_elements(context),
|
||||
|
||||
Reference in New Issue
Block a user