mercredi 6 mai 2015

jsreport .net client API returns empty PDF

I have recently setup jsreport as an embedded server in an ASP.NET application. After many struggles I have been able to generate html reports and return them to the browser using .net jsreport.Client with the following code in its simplest form.

Rightly or wrongly I have embedded jsreport into my existing VB application, and converted all example code from C# (I'm not a C# guy).

Imports System.Net
Imports System.Web.Http
Imports System.Net.Http
Imports System.Data
Imports System.Text.RegularExpressions
Imports System.IO
Imports System.Net.Http.Headers
Imports jsreport.Client
Imports jsreport.Client.Entities

<ActionName("ProcessReport")>
Public Async Function ProcessReport(ByVal reportID As Integer) As Threading.Tasks.Task(Of HttpResponseMessage)

Dim _reportingService = EmbeddedServer.ReportingService
Dim Report = Await _reportingService.RenderAsync(New RenderRequest() _ 
With {.template = New Template() _
     With {
          .recipe = "html",
          .content = "<h1>Some content</h1>"
         }
    }
)

Dim ReportContent As String = New StreamReader(Report.Content).ReadToEnd()
Dim response = New HttpResponseMessage()
response.StatusCode = HttpStatusCode.OK
response.Content = New StringContent(ReportContent)
response.Content.Headers.ContentType = New MediaTypeHeaderValue(Report.ContentType.MediaType)
Return response

End Function

But my problem is that I cannot produce a PDF using the phantom-pdf recipe as shown below. The ReportContent is a PDF document, but it is empty and has no content.

With {
     .recipe = "phantom-pdf",
     .content = "<h1>Some content</h1>"
    }

Please note that if I look in:

App_Data >> jsreport-net-embedded >> data >> temp

After running the above code there is a PDF which has the rendered content, but it is not being returned in the response.

Aucun commentaire:

Enregistrer un commentaire