如何消除 SimpleDocTemplate() 中的空格。 Python。报告实验室

发布于 2024-09-12 08:36:06 字数 1241 浏览 1 评论 0原文

有人知道当我使用 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

Do someone know if it possible to delete default spancing when i'm making PDF document with SimpleDocTemplate().

I want it to print from corner to corner.

   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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

够运 2024-09-19 08:36:06

尝试:

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

Try:

doc = SimpleDocTemplate(response, rightMargin=0, leftMargin=0, topMargin=0, bottomMargin=0)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文