2010-07-30 5 views
0

Est-ce que quelqu'un sait s'il est possible de supprimer la parité par défaut lorsque je crée un document PDF avec SimpleDocTemplate().Comment se débarrasser de l'espacement dans SimpleDocTemplate(). Python. ReportLab

Je veux imprimer du coin au coin.

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 

Répondre

2

Essayez:

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