Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions brazilfiscalreport/danfe/danfe.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ def __init__(self, xml, config: DanfeConfig = None):
self.logo_image = config.logo
self.receipt_pos = config.receipt_pos
self.default_font = config.font_type.value
self.default_font_factor = config.font_size.value
self.default_font_factor = (
config.font_size.value
if self.default_font == "Times"
else config.font_size.SMALL.value
)
self.price_precision = config.decimal_config.price_precision
self.quantity_precision = config.decimal_config.quantity_precision
self.invoice_display = config.invoice_display
Expand Down Expand Up @@ -500,7 +504,7 @@ def _product_col_widths(self, cst_width: float) -> Tuple[Optional[float], ...]:
if self.default_font_factor is FontSize.SMALL.value:
return (15, None, 11, cst_width, 7, 6, 12, 13, 13, 13, 10, 10, 9, 8)
elif self.default_font_factor is FontSize.BIG.value:
return (15, None, 14, 8, 8, 8, 12, 13, 13, 14, 13, 10, 9, 8)
return (15, None, 14, 8, 8, 8, 12, 13, 15, 14, 13, 10, 9, 9)

raise ValueError(f"Unsupported FontSize: {self.default_font_factor}")

Expand Down Expand Up @@ -885,7 +889,10 @@ def _draw_recipient_sender(self):

block_dest.add_field(
DanfeBasicField(
w=w_dest_end, description="ENDEREÇO", content=dest_end, pdf=self
w=w_dest_end,
description="ENDEREÇO",
content=self.long_field(text=dest_end, limit=100),
pdf=self,
)
)
block_dest.add_field(
Expand Down Expand Up @@ -1029,7 +1036,7 @@ def _draw_delivery_location(self):
DanfeBasicField(
w=widths["line2"]["endereco"],
description="ENDEREÇO",
content=endereco,
content=self.long_field(text=endereco, limit=100),
pdf=self,
)
)
Expand Down Expand Up @@ -1315,7 +1322,11 @@ def _draw_shipping(self):
]

fields_line2 = [
BaseFieldInfo(w=0, description="ENDEREÇO", content=ender),
BaseFieldInfo(
w=0,
description="ENDEREÇO",
content=self.long_field(text=ender, limit=50),
),
BaseFieldInfo(w=69, description="MUNICÍPIO", content=municipio),
BaseFieldInfo(w=8, description="UF", content=uf),
BaseFieldInfo(w=30, description="INSCRIÇÃO ESTADUAL", content=ie),
Expand Down
Binary file modified tests/generated/danfe/danfe_big_font_size.pdf
Binary file not shown.
Binary file modified tests/generated/danfe/danfe_infcpl_semicolon_newline.pdf
Binary file not shown.
Binary file modified tests/generated/danfe/danfe_overload.pdf
Binary file not shown.
Loading