【问题标题】:How to get rid of spacing in SimpleDocTemplate(). Python. ReportLab如何摆脱 SimpleDocTemplate() 中的间距。 Python。报告实验室
【发布时间】:2010-07-30 18:17:56
【问题描述】:

有人知道当我使用 SimpleDocTemplate() 制作 PDF 文档时是否可以删除默认间距。

我希望它从一个角落打印到另一个角落。

   response = HttpResponse(mimetype='application/pdf')
    response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'

    # Our container for 'Flowable' objects
    elements = []

    # A large collection of style sheets pre-made for us
    styles = getSampleStyleSheet()

    # A basic document for us to write to 'rl_hello_table.pdf'
    doc = SimpleDocTemplate(response)

    #    elements.append(Paragraph("Wumpus vs Cave Population Report",
#    styles['Title']))

    data = [
           ['Deep Ditch',    50],
           ['Death Gully',   5000],
           ['Dire Straits', 600],
           ['Deadly Pit',    5],
           ['Deep Ditch',    50],
           ['Deep Ditch',    50],
           ['Death Gully',   5000],
           ['Dire Straits', 600],
           ['Deadly Pit',    5],
           ['Deep Ditch',    50],
                                  ]

    # Create the table with the necessary style, and add it to the
    # elements list.
    table = Table(data, colWidths=270, rowHeights=70)
    elements.append(table)

    # Write the document to response
    doc.build(elements) 

    return response

【问题讨论】:

    标签: python django pdf-generation


    【解决方案1】:

    试试:

    doc = SimpleDocTemplate(response, rightMargin=0, leftMargin=0, topMargin=0, bottomMargin=0)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-21
      • 1970-01-01
      • 1970-01-01
      • 2011-12-27
      • 1970-01-01
      • 2011-04-21
      • 2021-10-25
      • 2010-10-02
      相关资源
      最近更新 更多