title: Render XHTML on one page to PDF
body: <p>I have XHTML containing shop receipt. I am trying to generate PDF out of it. Generation is not problem at all. But I would like to have &quot;break-less&quot; page (whole content fits to one page).</p>
  <p>I have Koltin Spring project and using flying-saucer.</p>
  <p>org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.22</p>
  <p>Code is simple as this:</p>
  <pre><code>fun generatePDF(templateString: String): ByteArrayOutputStream {
      val renderer = ITextRenderer()
  
      renderer.sharedContext.also {
          it.isPrint = true
          it.isInteractive = false
          it.textRenderer.setSmoothingThreshold(0F)
      }
  
      renderer.setDocumentFromString(templateString, baseUrl)
      renderer.layout()
  
      val baos = ByteArrayOutputStream()
  
      renderer.createPDF(baos)
      renderer.finishPDF()
  
      return baos
  }
  </code></pre>
  <p>Is it somehow possible to do it?</p>
  <p>Note: I've found some information about page size in the <a href="https://flyingsaucerproject.github.io/flyingsaucer/r8/guide/users-guide-R8.html#xil_34" rel="nofollow noreferrer">documentation</a>, but I am not sure how to use it if I don't know the exact size (items in receipt are calculated).</p>