本文整理汇总了Python中reportlab.platypus.SimpleDocTemplate.rightMargin方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleDocTemplate.rightMargin方法的具体用法?Python SimpleDocTemplate.rightMargin怎么用?Python SimpleDocTemplate.rightMargin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.SimpleDocTemplate
的用法示例。
在下文中一共展示了SimpleDocTemplate.rightMargin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_pdf
# 需要导入模块: from reportlab.platypus import SimpleDocTemplate [as 别名]
# 或者: from reportlab.platypus.SimpleDocTemplate import rightMargin [as 别名]
def create_pdf(self):
pdf = StringIO.StringIO()
doc = SimpleDocTemplate(pdf)
doc.leftMargin=31
doc.rightMargin=31
doc.topMargin=390
doc.bottomMargin=110
story = []
order_items = [["Artikelnr.", "Name", "Menge", "Preis", "Summe"]]
for item in self.order.items.all():
amount = str(item.amount) + " " + item.product.unit
price = currency(item.product_price_gross)
total = currency(item.price_gross)
order_items.append([item.product.sku, item.product_name, amount, price, total])
order_items_table = Table(order_items, (80, 238, 60, 70, 70))
order_items_table.setStyle(dn_order_items_style)
story.append(order_items_table)
story.append(Spacer(1, 40))
# END
story.append(Paragraph(getattr(settings, "DN_END"), styleN))
doc.build(story, onFirstPage=self.page, onLaterPages=self.page)
pdf.seek(0)
return pdf
示例2: start_pdf
# 需要导入模块: from reportlab.platypus import SimpleDocTemplate [as 别名]
# 或者: from reportlab.platypus.SimpleDocTemplate import rightMargin [as 别名]
def start_pdf(mdata):
global doc, elements, dwidth, dheight
pdf_file = os.path.join(PDF_DIR, mdata['title'] + '.pdf')
doc = SimpleDocTemplate(pdf_file, pagesize=letter)
elements = []
dwidth, dheight = letter
# margins
doc.topMargin = TOP_MARGIN
doc.leftMargin = LEFT_MARGIN
doc.bottomMargin = TOP_MARGIN
doc.rightMargin = LEFT_MARGIN
示例3: doPrint
# 需要导入模块: from reportlab.platypus import SimpleDocTemplate [as 别名]
# 或者: from reportlab.platypus.SimpleDocTemplate import rightMargin [as 别名]
def doPrint(self, app, qrcode_value, raw_score):
pdf_file_name = tempfile.mktemp (".pdf")
styles = getSampleStyleSheet ()
h1 = styles["h1"]
h1.alignment=TA_CENTER
h1.fontSize = 36
h1.spaceBefore = 10
h1.spaceAfter = 22
normal = styles["Normal"]
normal.alignment=TA_CENTER
normal.fontSize = 16
starStyle = ParagraphStyle(name='Star',
fontName='FontAwesome',
fontSize=20,
alignment=TA_CENTER,
spaceAfter = 18)
doc = SimpleDocTemplate (pdf_file_name)
doc.pagesize = (8*cm, 29*cm)
doc.topMargin = 0
doc.leftMargin = 0
doc.rightMargin = 0
wheel_threshold = app.config.get('wheel_threshold')
number_questions = app.config.get('number_questions')
percent = float(raw_score) / float(number_questions)
canWheel = float(percent) >= float(wheel_threshold) / float(number_questions)
parts = []
imagename = "images/stylo.png"
normal.spaceAfter = 18
if canWheel:
parts.append(Paragraph(app.config.get('wheel_txt'), normal))
d = barcode.createBarcodeDrawing("QR", width=4*cm, height=4*cm, barBorder=0, value=qrcode_value)
d.hAlign = "CENTER"
d.vAlign = "TOP"
parts.append(d)
else:
parts.append(Paragraph(app.config.get('no_wheel_txt'), normal))
parts.append(Image(imagename, 4*cm, 4*cm))
raw_score = min(raw_score, len(app.config.scoreValueTable())-1)
parts.append(Paragraph(str(app.config.scoreValueTable()[raw_score]), h1))
empty_star = u"\uF006"
full_star = u"\uF005"
stars = u""
if percent <= 0.3:
stars += 3 * empty_star
elif percent < 0.6:
stars += full_star + 2 * empty_star
elif percent < 1:
stars += 2 * full_star + empty_star
else:
stars += 3 * full_star
parts.append(Paragraph(stars, starStyle))
parts.append(Paragraph(app.config.get('url'), normal))
doc.build(parts)
#call([app.config.get('acrobat'), "", pdf_file_name])
call([app.config.get('foxit'), "/t", pdf_file_name, app.config.get('printer_name')])