本文整理汇总了Python中reportlab.platypus.BaseDocTemplate.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python BaseDocTemplate.__init__方法的具体用法?Python BaseDocTemplate.__init__怎么用?Python BaseDocTemplate.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.BaseDocTemplate
的用法示例。
在下文中一共展示了BaseDocTemplate.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self,title, author, filename=None, size=(4,6), sb=0):
(height,width,) = size
if not filename:
self.filename="%s-%sx%s.pdf" % (title,str(height),str(width))
else:
self.filename=filename
pagesize = (width*inch,height*inch)
F=Frame(0,0,width*inch,height*inch,
leftPadding=0.5*inch,
bottomPadding=0.50*inch,
rightPadding=0.25*inch,
topPadding=0.25*inch,
showBoundary=sb)
PT = PageTemplate(id="Notecard", frames=[F,])
BaseDocTemplate.__init__(self, self.filename,
pageTemplates=[PT,],
pagesize=pagesize,
showBoundary=sb,
leftMargin=0,
rightMargin=0,
topMargin=0,
bottomMargin=0,
allowSplitting=1,
title=title,
author=author)
示例2: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, filename, **kw):
frame1 = Frame(2.5*cm, 2.5*cm, 16*cm, 25*cm, id='Frame1')
self.allowSplitting = 0
self.showBoundary = 1
BaseDocTemplate.__init__(self, filename, **kw)
template = PageTemplate('normal', [frame1], myMainPageFrame)
self.addPageTemplates(template)
示例3: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, name, teacher):
self.PAGE_WIDTH = A4[0]
self.PAGE_HEIGHT = A4[1]
self.CENTRE_WIDTH = self.PAGE_WIDTH/2.0
self.CENTRE_HEIGHT = self.PAGE_HEIGHT/2.0
BaseDocTemplate.__init__(self,name, pagesize=A4, topMargin=0.5*cm)
self.fileName = name
self.teacher = teacher
示例4: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, *args, **kwargs):
from reportlab.lib.units import cm
if not kwargs.has_key('leftMargin'): kwargs['leftMargin'] = 1.5 * cm
if not kwargs.has_key('rightMargin'): kwargs['rightMargin'] = 1.5 * cm
if not kwargs.has_key('bottomMargin'): kwargs['bottomMargin'] = 1.5 * cm
BaseDocTemplate.__init__(self, *args, **kwargs)
示例5: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, *args, **kwargs):
BaseDocTemplate.__init__(self, *args, **kwargs)
self.numPages = 0
self._lastNumPages = 0
self.setProgressCallBack(self._onProgress_cb)
# For batch reports with several PDFs concatenated
self.restartDoc = False
self.restartDocIndex = 0
self.restartDocPageNumbers = []
示例6: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, *args, **kw):
BaseDocTemplate.__init__(self, *args, **kw)
doc = self
columns = []
columns.append(FancyFrame(doc.leftMargin, doc.bottomMargin, doc.width, doc.height))
#doc.showBoundary = True
doc.addPageTemplates([
PageTemplate(id='OneColumn', frames=columns),
])
示例7: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, *args, **kwargs):
# letter 21.6 x 27.9
kwargs['pagesize'] = letter
kwargs['rightMargin'] = 1 * cm
kwargs['leftMargin'] = 1 * cm
kwargs['topMargin'] = 4 * cm
kwargs['bottomMargin'] = 2 * cm
BaseDocTemplate.__init__(self, *args, **kwargs)
self.styles = getSampleStyleSheet()
self.header = {}
self.data = []
示例8: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, *args, **kw):
BaseDocTemplate.__init__(self, *args, **kw)
doc = self
columns = []
columns.append(FancyFrame(doc.leftMargin, doc.bottomMargin,
doc.width, doc.height))
doc.addPageTemplates([
PageTemplate(id='OneColumn', frames=columns),
])
doc.pageheader = None
doc.pagefooter = None
示例9: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, *args, **kwargs):
self.has_title_page = kwargs.pop('has_title_page', False)
frame = Frame(
left_margin, bottom_margin, frame_width, frame_height,
id='normal',
leftPadding=0, topPadding=0, rightPadding=0, bottomPadding=0
)
pageTemplates = [
PageTemplate(id='standard', frames=[frame])
]
BaseDocTemplate.__init__(
self, pageTemplates=pageTemplates, *args, **kwargs
)
示例10: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self,
title = "Sahana Eden",
margin = (0.5 * inch, # top
0.3 * inch, # left
0.5 * inch, # bottom
0.3 * inch), # right
margin_inside = 0.0 * inch, # used for odd even pages
paper_size = None,
paper_alignment = "Portrait"):
"""
Set up the standard page templates
"""
self.output = StringIO()
self.defaultPage = paper_alignment
if paper_size:
self.paper_size = paper_size
else:
settings = current.deployment_settings
if settings.get_paper_size() == "Letter":
self.paper_size = LETTER
else:
self.paper_size = A4
self.topMargin = margin[0]
self.leftMargin = margin[1]
self.bottomMargin = margin[2]
self.rightMargin = margin[3]
self.insideMargin = margin_inside
BaseDocTemplate.__init__(self,
self.output,
title = title,
leftMargin = self.leftMargin,
rightMargin = self.rightMargin,
topMargin = self.topMargin,
bottomMargin = self.bottomMargin,
)
self.MINIMUM_MARGIN_SIZE = 0.2 * inch
self.body_flowable = None
self._calc()
示例11: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, *args, **kwargs):
x = 2*cm
w_form1, h_form1 = W/2, 2.7*cm
w_form2, h_form2 = W/2 - 4*cm, h_form1
y_form = H - 5*cm
w_table, h_table = (W - 3.9*cm)/5, 17.5*cm
y_table = H - h_table - 6*cm
w_logo, h_logo = 3.4*cm, 2.5*cm
y_logo = H - 2*cm
w_title, h_title = 5 * w_table, 0.6*cm
w_serial, h_serial = 5*cm, h_title
x_serial, y_serial = W - w_serial - 2*cm, H - h_serial
y_title = y_table + h_table
x_signature, y_signature = 2*cm, 2*cm
w_signature, h_signature = 5*cm, 2*cm
pad = dict(('%sPadding' % d, 0) for d in ['left', 'right', 'top', 'bottom'])
t1 = PageTemplate(id='p1', frames=[
Frame(x, y_logo, w_logo, h_logo, id='logo', **pad),
Frame(x_serial, y_serial, w_serial, h_title, id='serial', **pad),
Frame(x, y_form, w_form1, h_form1, id='left', **pad),
Frame(x + w_form1, y_form, w_form2, h_form2, id='right', **pad),
Frame(x, y_title, w_title, h_title, id='title', **pad),
Frame(x, y_table, w_table, h_table, id='panel1', **pad),
Frame(x + 1*w_table, y_table, w_table, h_table, id='panel2', **pad),
Frame(x + 2*w_table, y_table, w_table, h_table, id='panel3', **pad),
Frame(x + 3*w_table, y_table, w_table, h_table, id='panel4', **pad),
Frame(x + 4*w_table, y_table, w_table, h_table, id='panel5', **pad),
], onPage=self.printFooter)
h_table = H - 4*cm
t2 = PageTemplate(id='p2', frames=[
Frame(x, y_table, w_table, h_table, id='panel1', **pad),
Frame(x + 1*w_table, y_table, w_table, h_table, id='panel2', **pad),
Frame(x + 2*w_table, y_table, w_table, h_table, id='panel3', **pad),
Frame(x + 3*w_table, y_table, w_table, h_table, id='panel4', **pad),
Frame(x + 4*w_table, y_table, w_table, h_table, id='panel5', **pad),
], onPage=self.printFooter)
#kwargs['showBoundary'] = True
BaseDocTemplate.__init__(self, *args, **kwargs)
self.addPageTemplates([t1, t2])
示例12: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, request, report_name="Test PDF", title="Test PDF", subtitle=None, pagesize=A4, background=None, **kwargs):
self.request = request
self.report_name = report_name
self.title = title
self.subtitle = subtitle
self.response = HttpResponse(content_type='application/pdf')
self.response['Content-Disposition'] = 'attachment; filename=\"%s.pdf\"' % self.report_name
#ReportLab uses old style classes, so super() doesn't work.
BaseDocTemplate.__init__(self, self.response, pagesize=pagesize, **kwargs)
if background != None:
bg_image = BackgroundImage(background, pagesize)
else:
bg_image = None
self.addPageTemplates([
CoverPageTemplate(title, subtitle, background=bg_image)
, ReportPageTemplate(id='basic', pagesize=pagesize, background=bg_image)
, ReportPageTemplate(id='2col', columns=2, pagesize=pagesize, background=bg_image)
])
示例13: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self,filename, title, author):
self.filename = filename
# (WIDTH,HEIGHT)
pageSize = (6*inch,4*inch)
#Frame(x1, y1, width,height, leftPadding=6, bottomPadding=6,
# rightPadding=6, topPadding=6, id=None, showBoundary=0)
F = Frame(0,0,6*inch,4*inch,
leftPadding=0.25*inch,
bottomPadding=0.50*inch,
rightPadding=0.25*inch,
topPadding=0.25*inch,
showBoundary=1)
PT = PageTemplate(id="Notecard", frames=[F,])
BaseDocTemplate.__init__(self, self.filename,
pageTemplates=[PT,],
pagesize=pageSize,
showBoundary=1,
leftMargin=0,
rightMargin=0,
topMargin=0,
bottomMargin=0,
allowSplitting=1,
title=title,
author=author)
示例14: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self, instance):
# Configuración
filename = ruta + 'media/kids/guias/%d.pdf' % instance.id
self.estilos = {
'texto': ParagraphStyle(name='texto',
alignment=TA_JUSTIFY,
fontName='PatrickHand',
fontSize=12,
leading=17,
firstLineIndent=20,
),
'pregunta': ParagraphStyle(name='pregunta',
alignment=TA_JUSTIFY,
fontName='PatrickHand',
fontSize=12,
leading=20,
firstLineIndent=30,
),
'puntos': ParagraphStyle(name='puntos',
alignment=TA_JUSTIFY,
fontName='PatrickHand',
fontSize=12,
leading=25,
),
'cabecera': ParagraphStyle(name='cabecera',
alignment=TA_RIGHT,
fontName='GloriaHallelujah',
fontSize=9,
leading=14,
textColor='#444444',
),
'titulo': ParagraphStyle(name='titulo',
alignment=TA_CENTER,
fontName='PermanentMarker',
fontSize=20,
leading=20,
textColor='#00338e',
),
'subtitulo': ParagraphStyle(name='subtitulo',
alignment=TA_JUSTIFY,
fontName='Julee',
fontSize=14,
leading=20,
textColor='#00338e',
),
'versiculo': ParagraphStyle(name='versiculo',
alignment=TA_RIGHT,
fontName='PatrickHand',
fontSize=12,
leading=14,
firstLineIndent=100,
),
'pupiletras': ParagraphStyle(name='pupiletras',
alignment=TA_CENTER,
fontName='DroidSansMono',
fontSize=12,
leading=15,
),
}
self.story = []
self.header = 'Iglesia "La Palabra y El Espíritu"'
BaseDocTemplate.__init__(self, filename)
self.mostrar = 0
self.allowSplitting = 1
self.showBoundary = self.mostrar
self.MARGEN = 0.5 * cm
a4 = A4
margen = self.MARGEN
frameDatos = Frame(self.MARGEN * 2, self.MARGEN,
A4[0] - 4 * self.MARGEN, A4[1] - 4 * self.MARGEN,
id='datos', showBoundary=self.mostrar)
height = frameDatos.height
template = PageTemplate('pagina_normal', [frameDatos],
self.formato)
self.addPageTemplates(template)
self.insertar(instance.nombre, 'titulo')
self.insertar(u'Versículos de Estudio', 'subtitulo')
estilo = 'texto'
for linea in instance.versiculo.splitlines():
self.insertar(linea, estilo)
if estilo == 'texto':
estilo = 'versiculo'
else:
estilo = 'texto'
self.insertar(u'Bosquejo', 'subtitulo')
estilo = 'texto'
for linea in instance.bosquejo.splitlines():
self.insertar(linea, estilo)
self.insertar('Temas', 'subtitulo')
for linea in instance.temas.splitlines():
self.insertar('- ' + linea, 'texto')
self.story.append(PageBreak())
alto = 20
alto += self.insertar(instance.nombre, 'titulo')
alto += self.insertar(u'Versículo Para Memorizar', 'subtitulo')
estilo = 'texto'
for linea in instance.memorizar.splitlines():
alto += self.insertar(linea, estilo)
if estilo == 'texto':
estilo = 'versiculo'
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from reportlab.platypus import BaseDocTemplate [as 别名]
# 或者: from reportlab.platypus.BaseDocTemplate import __init__ [as 别名]
def __init__(self,
pagesize,
cardsize,
margins = None,
spacing = None,
title = None,
):
"""
Constructor
@param pagesize: the page size, tuple (w, h)
@param cardsize: the card size, tuple (w, h)
@param margins: the page margins, tuple (N, E, S, W)
@param spacing: the spacing between cards, tuple (H, V)
@param title: the document title
- all sizes in points (72 points per inch)
"""
# Spacing between cards
if spacing is None:
spacing = (18, 18)
elif not isinstance(spacing, (tuple, list)):
spacing = (spacing, spacing)
# Page margins
if margins is None:
margins = self.compute_margins(pagesize, cardsize, spacing)
elif not isinstance(margins, (tuple, list)):
margins = (margins, margins, margins, margins)
# Cards per row, rows per page and cards per page
pagewidth, pageheight = pagesize
cardwidth, cardheight = cardsize
number_of_cards = self.number_of_cards
cards_per_row = number_of_cards(pagewidth,
cardwidth,
(margins[1], margins[3]),
spacing[0],
)
rows_per_page = number_of_cards(pageheight,
cardheight,
(margins[0], margins[2]),
spacing[1],
)
self.cards_per_row = cards_per_row
self.rows_per_page = rows_per_page
self.cards_per_page = rows_per_page * cards_per_row
# Generate page templates
pages = self.page_layouts(pagesize, cardsize, margins, spacing)
if title is None:
title = current.T("Items")
# Call super-constructor
BaseDocTemplate.__init__(self,
None,
pagesize = pagesize,
pageTemplates = pages,
topMargin = margins[0],
rightMargin = margins[1],
bottomMargin = margins[2],
leftMargin = margins[3],
title = s3_str(title),
)