title: How to wrap multiple paragraphs in one element?
body: <p>I'm creating a fairly complex PDF document in Java using iText 5. I add a bunch of <code>Paragraph</code> objects to my document. To improve readability of my code, I would like to create multiple methods to create different aspects of the document.</p>
  
  <p>What type can I use to wrap multiple <code>Paragraph</code> objects in one unit, so I can return them from my sub-methods? The <code>Element</code> class does not have an <code>add()</code> method, nor does the <code>Chunk</code> class.</p>
  
  <p>I tried <code>Phrase</code>, but then I lose all line breaks. Wrapping my <code>Paragraph</code> objects in another <code>Paragraph</code> object produces the desired output, but it feels odd, and I fear that the wrapping paragraph might introduce additional margins in the document.</p>
  
  <p>So what is the best type for wrapping <code>Paragraph</code> objects in order to group them logically?</p>
  
  <hr>
  
  <h2>Code example</h2>
  
  <p>My current code:</p>
  
  <pre><code>Document doc = new Document(...);
  doc.add(new Paragraph("Aspect A.1"));
  doc.add(new Paragraph("Aspect A.2"));
  doc.add(new Paragraph("Aspect A.3"));
  
  doc.add(new Paragraph("Aspect B.1"));
  doc.add(new Paragraph("Aspect B.2"));
  </code></pre>
  
  <p>What I'm striving for:</p>
  
  <pre><code>Document doc = new Document(...);
  doc.add(createAspectA());
  doc.add(createAspectB());
  
  // ...
  
  private WrapperElement createAspectA() {
    WrapperElement wrapper = new WrapperElement(...);
  
    wrapper.add(new Paragraph("Aspect A.1"));
    wrapper.add(new Paragraph("Aspect A.2"));
    wrapper.add(new Paragraph("Aspect A.3"));
  
    return wrapper;
  }
  
  private WrapperElement createAspectB() {
    WrapperElement wrapper = new WrapperElement(...);
  
    wrapper.add(new Paragraph("Aspect B.1"));
    wrapper.add(new Paragraph("Aspect B.2"));
  
    return wrapper;
  }
  </code></pre>