|
|
@ -3,7 +3,7 @@ |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|
|
# Classe para geração de PDF da DANFE a partir de xml etree.fromstring |
|
|
# Classe para geração de PDF da DANFE a partir de xml etree.fromstring |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import os |
|
|
from io import BytesIO |
|
|
from io import BytesIO |
|
|
from textwrap import wrap |
|
|
from textwrap import wrap |
|
|
|
|
|
|
|
|
@ -20,7 +20,6 @@ from reportlab.pdfbase import pdfmetrics |
|
|
from reportlab.pdfbase.ttfonts import TTFont |
|
|
from reportlab.pdfbase.ttfonts import TTFont |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def chunks(cString, nLen): |
|
|
def chunks(cString, nLen): |
|
|
for start in range(0, len(cString), nLen): |
|
|
for start in range(0, len(cString), nLen): |
|
|
yield cString[start:start+nLen] |
|
|
yield cString[start:start+nLen] |
|
|
@ -75,10 +74,14 @@ def get_image(path, width=1*cm): |
|
|
class danfe(object): |
|
|
class danfe(object): |
|
|
def __init__(self, sizepage=A4, list_xml=None, recibo=True, |
|
|
def __init__(self, sizepage=A4, list_xml=None, recibo=True, |
|
|
orientation='portrait', logo=None): |
|
|
orientation='portrait', logo=None): |
|
|
|
|
|
|
|
|
|
|
|
path = os.path.join(os.path.dirname(__file__), 'fonts') |
|
|
pdfmetrics.registerFont( |
|
|
pdfmetrics.registerFont( |
|
|
TTFont('NimbusSanL-Regu', '../fonts/NimbusSanL Regular.ttf')) |
|
|
|
|
|
|
|
|
TTFont('NimbusSanL-Regu', |
|
|
|
|
|
os.path.join(path, 'NimbusSanL Regular.ttf'))) |
|
|
pdfmetrics.registerFont( |
|
|
pdfmetrics.registerFont( |
|
|
TTFont('NimbusSanL-Bold', '../fonts/NimbusSanL Bold.ttf')) |
|
|
|
|
|
|
|
|
TTFont('NimbusSanL-Bold', |
|
|
|
|
|
os.path.join(path, 'NimbusSanL Bold.ttf'))) |
|
|
self.width = 210 # 21 x 29,7cm |
|
|
self.width = 210 # 21 x 29,7cm |
|
|
self.height = 297 |
|
|
self.height = 297 |
|
|
self.nLeft = 10 |
|
|
self.nLeft = 10 |
|
|
|