title: How to use Reportlab platypus ( Align paragraph )
body: <p>I'm trying to create a PDF from python using reportlab and the Playtipus module.</p>
  
  <p>I want the pdf look like that :
  <a href="https://i.stack.imgur.com/wXFb0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wXFb0.png" alt="Expected result "></a></p>
  
  <p>The problem is that i don't understand how to handle the layout.
  I created a simple PageTemplate which is the main Page, with a simple Frame
  But inside this simple frame, i need a flowable with "two colonne" layout.</p>
  
  <p>The page template : </p>
  
  <pre><code>class PageOne(PageTemplate):
  
  def __init__(self, context):
      self.context = context
      self.largeur = self.context.doc.pagesize[0]
      self.hauteur = self.context.doc.pagesize[1]
  
      self.simpleFrame = Frame(self.context.doc.leftMargin, self.context.doc.bottomMargin, self.context.doc.width, self.context.doc.height - 3*cm, id='normal');
      PageTemplate.__init__(self, id="PageOne", frames=[self.simpleFrame], pagesize = A4, onPage = CommonReportPdf.footer_and_header)
      print("here 1 ")   
  
  def beforeDrawPage(self, canvas, doc):
      canvas.saveState()
      try:
          print("beforeDrawPage")
      finally:
          canvas.restoreState()
  </code></pre>
  
  <p>The custom section model (represent a part with the associated tests):</p>
  
  <pre><code>class CustomSection(Flowable):
  
  def __init__(self, x=0, y=-15, width=80, height=15, title="", flowables=[]):
      Flowable.__init__(self)
      self.x = x
      self.y = y
      self.width = width
      self.height = height
      self.title = title
      self.styles = getSampleStyleSheet()        
  
  def __repr__(self):
      return "CustomSection(w=%s)" % self.width
  
  def _draw_title(self):
      print("draw title")
      self.canv.rect(self.x, self.y, self.width, self.height)
      self.canv.line(self.x, 0, 500, 0)
  
      p = Paragraph(self.title, style=self.styles["Normal"])
      p.wrapOn(self.canv, self.width, self.height)
      p.drawOn(self.canv, *self.coord(self.x+2, 10, mm))
  
  def draw(self):
      self.canv.saveState()
      try:
          self._draw_title()
          # Here add SectionItemWithValue or SectionItemWithoutValue to this flowable
      finally:
          self.canv.restoreState()
  
  def coord(self, x, y, unit=1):
      """
      http://stackoverflow.com/questions/4726011/wrap-text-in-a-table-reportlab
      Helper class to help position flowables in Canvas objects
      """
      x, y = x * unit, self.height - y * unit
      return x, y
  </code></pre>
  
  <p>The flowables : </p>
  
  <pre><code>class SectionItemWithValue(Flowable):
  
      def __init__(self, title, result, value, x=0, y=-15, width=80, height=15):
          self.title = title
          self.result = result
          self.value = value
  
      def draw(self):
          self.canv.saveState()
          try:
              print("ok")
          finally:
              self.canv.restoreState()
  
  class SectionItemWithoutValue(Flowable):
  
      def __init__(self, title, result, x=0, y=-15, width=80, height=15):
          self.title = title
          self.result = result
  
      def draw(self):
          self.canv.saveState()
          try:
              print("ok")
          finally:
              self.canv.restoreState()
  </code></pre>
  
  <p>Pdf generation class :</p>
  
  <pre><code>class XmlToPdf:
  
  def __init__(self, xml_file):
  
      #self.root_xml = self.init_xml(xml_file)
      destination_path = "XmlToPdf.pdf"
      self.elements = []
      self.doc = BaseDocTemplate(destination_path, showBoundary=0, leftMargin=0.7 * cm, rightMargin=0.7*cm, topMargin=0.7*cm, bottomMargin=0.7*cm, pagesize=A4)
      self.simpleFrame = Frame(self.doc.leftMargin, self.doc.bottomMargin, self.doc.width, self.doc.height - 5*cm, id='normal')
  
  def init_xml(self, xml_file):
      tree = ET.parse(xml_file)
      return tree.getroot()  
  
  def create_pdf(self):
      styles = getSampleStyleSheet()
  
      _baseFontNameBI = tt2ps(_baseFontName, 1, 1)
  
      styles.add(ParagraphStyle(name='RightAlign', alignment=TA_RIGHT))
      styles.add(ParagraphStyle(name='LeftAlign', alignment=TA_LEFT))
  
      self.elements.append(Paragraph("Frame two columns,  "*2,styles['LeftAlign'])) #  I want both on the same line
      self.elements.append(Paragraph("Frame two columns,  "*2,styles['RightAlign'])) #  I want both on the same line
      self.elements.append(PageBreak())
      self.elements.append(Paragraph("Une colonne",styles['Normal']))
      self.elements.append(PageBreak())
  
      textWidth = stringWidth("Test title 1  ", _baseFontNameBI, 14)
      box = CustomSection(title="Contrôle logiciels", width=textWidth)
      self.elements.append(box)
  
      self.elements.append(Spacer(0, 20))
  
      self.elements.append(Paragraph("This is a paragraph", styles["Normal"]))
  
      textWidth = stringWidth("Test title 2", _baseFontNameBI, 14)        
      box = CustomSection(title="Test title 2", width=textWidth)
      self.elements.append(box)        
      self.elements.append(Spacer(0, 1*inch))
  
      textWidth = stringWidth("Test title 3", _baseFontNameBI, 14)
      box = CustomSection(title="Test title 3", width=textWidth)
      self.elements.append(box)        
      self.elements.append(Spacer(0, 1*inch))
  
      textWidth = stringWidth("Test title 4", _baseFontNameBI, 14)        
      box = CustomSection(title="Test title 5", width=textWidth)
      self.elements.append(box)        
      self.elements.append(Spacer(0, 1*inch))                        
  
      self.doc.totalPages = 4
      templates = [PageOne(self)]
  
      self.doc.addPageTemplates(templates)
      self.doc.build(self.elements)
  </code></pre>
  
  <p>Im i using the right components ? Did you have some "complex" document exemple ? How to handle Layout and paragraph ? Should i use a table ? </p>