我最近将jsreport设置为ASP.NET应用程序中的嵌入式服务器。 经过很多的努力,我已经能够生成html报告并使用.net jsreport.Client以最简单的形式将下面的代码返回给浏览器。jsreport .net客户端API返回空PDF
正确或错误我已将jsreport嵌入到现有的VB应用程序中,并将所有示例代码转换为C#(我不是C#人员)。
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
但我的问题是,我不能使用phantom-pdf配方生成PDF,如下所示。 ReportContent是一个PDF文档,但它是空的并且没有内容。
With {
.recipe = "phantom-pdf",
.content = "<h1>Some content</h1>"
}
请注意,如果我期待在:
的App_Data >> jsreport净嵌入式>>数据>>临时
运行上面的代码后有已呈现一个PDF内容,但不会在回复中返回。