title: generate pdf with dynamic content using scala and play framework
body: <p>I have a list of sessions when clicking on a session I get it and send the id to my method using angularJs:</p>
  
  <pre><code>  def getSession(idSession: UUID) = Action.async(parse.json) { request =&gt;
      sessionService.findById(idSession).map {
        case Some(session) =&gt;
          Ok(views.html.result.printPdf(session))
        case None =&gt; NotFound(Json.toJson("Not found"))
  
      }
    }
  </code></pre>
  
  <p>My method works fine but it don't redirect to the view "prindpdf" also how can I call my second function which generate the pdf and take the session as parameter here is my second function:</p>
  
  <pre><code>  def homepage: Action[AnyContent] = Action { implicit request =&gt;
      Ok(new PdfGenerator().toBytes(views.html.result.printPdf("Your PDF is generated"), "http://localhost:9000")).as("application/pdf")
    }
  </code></pre>
  
  <p>and this is my view:</p>
  
  <pre><code>@(message: models.Session)
  @mainPdf("Welcome") {
      Image: &lt;img src="/public/images/favicon.png"/&gt;&lt;br/&gt;
      Hello world! &lt;br/&gt;
      @message
  }
  </code></pre>