title: itext7 - How to draw horizontal dashed line in PDF?
body: <p>I am using the community version of itext7 (version <code>7.1.9</code>).
  I would like to create a PDF document where I insert text paragraphs and a horizontal divider in between like so:</p>
  
  <pre><code>some interesting text
  -----------
  more interesting text
  -----------
  still interesting text
  -----------
  you get the idea
  -----------
  </code></pre>
  
  <p>To realise this document structure I am using <code>Paragraph</code>s and a <code>LineSeparator</code> in conjunction with the <code>DashedLine</code> class. However, even with a minimal example the individual dashes end up <strong>vertical</strong>, like so:</p>
  
  <pre><code>some interesting text
  |||||||||||||
  more interesting text
  |||||||||||||
  </code></pre>
  
  <p>The overall separator still runs horizontally, but passing a <code>width</code> parameter (as defined in Javadoc) seems to actually give <em>height</em> to the lines. Am I doing something wrong here?</p>
  
  <p>What can I do to generate a separator with horizontal dashed lines where the dashes themselves are also horizontal (width of 30.0 is a generic example)?</p>
  
  <p>Minimal reproduction example (Kotlin):</p>
  
  <pre><code>import com.itextpdf.io.font.constants.StandardFonts
  import com.itextpdf.kernel.font.PdfFontFactory
  import com.itextpdf.kernel.pdf.PdfDocument
  import com.itextpdf.kernel.pdf.PdfWriter
  import com.itextpdf.kernel.pdf.canvas.draw.DashedLine
  import com.itextpdf.layout.Document
  import com.itextpdf.layout.element.LineSeparator
  import com.itextpdf.layout.element.Paragraph
  import java.io.File
  
  object DashedLineBugReproduction {
      private fun render() {
          val docWriter = PdfWriter(File("/tmp/foobar_dashes.pdf"))
          val document = PdfDocument(docWriter)
  
          document.writeContents()
  
          document.close()
      }
  
      fun PdfDocument.writeContents() {
          val doc = Document(this)
  
          val font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN)
  
          val dashedLine = LineSeparator(DashedLine(30f))
          val paragraph = Paragraph("Lorem ipsum dolor sit amet.")
              .setFont(font)
              .setFontSize(20f)
  
          doc.add(dashedLine)
  
          for (i in 0 until 8) {
              doc.add(paragraph)
              doc.add(dashedLine)
          }
  
          doc.close()
      }
  
      @JvmStatic
      fun main(args: Array&lt;String&gt;) {
          render()
      }
  }
  </code></pre>
  
  <p>Resulting output file (screenshot, I can provide the PDF if required):
  <a href="https://i.stack.imgur.com/ijkev.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ijkev.png" alt="problematic output"></a></p>