Score:0

Include jasper report in drupal 9

in flag

I want to print a report from the Jasper Report Server in Drupal. I use their PHP Client in my own controller.

$report = $jasperClient->reportService()->runReport($pathJS, $format, null, null, $controls);

I have an answer from the server and the images are displayed for a simple report, but when the report contains JavaScript code, the page remains white.

I tried using the following code.

$response = New Response();
$response->setContent($report);
return $response;

The report opens in a new page (not themed by Drupal) and all the elements are presents in the page. I want to integrate it into Drupal, so I created my own html.twig file. In my controller I use the following code.

$build = array(
  '#type' => 'inline_template',
  '#format' => 'full_html',
  '#theme' => 'jasperReportTheme',
  '#response' =>  $report
);

return $build;

The HTML markup from Jasper is displayed as text. To test I put this text into a test.html file and opened with a browser. Everything looks ok just in Drupal the HTML code is displayed as text. In my html.twig template I tried several possibilities such as {{Response}} or {{Response | RAW}} without success.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.