|
Rank: Advanced Member Groups: Member
Joined: 12/14/2018 Posts: 31
|
We are using Web API to generate PDF, MVC app does not fit to our application structure. Please try the same sample by taking Web API and host on Azure app Service running on 64 bit. As mentioned in the first post, below code we use to return the response stream from API.
Code: C#
HtmlToPdfOptions op = new HtmlToPdfOptions();
op.HeaderHtmlFormat = "Header content";
op.FooterHtmlFormat = "Footer content";
MemoryStream pdfStream = new MemoryStream();
{
HtmlToPdf.ConvertHtml("our html content", pdfStream, op);
byte[] pdfFileBytes = pdfStream.ToArray();
MemoryStream outPutStream = new MemoryStream(pdfFileBytes);
response.Content = new PushStreamContent((responseStream, httpContent, tc) =>
{
outPutStream.CopyTo(responseStream);
responseStream.Close();
}, "application/octet-stream");
HttpStatusCode successStatus = HttpStatusCode.Created;
response.StatusCode = successStatus;
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = "sample.pdf";
response.Content.Headers.ContentLength = new MemoryStream(pdfFileBytes).Length;
return response;
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,258
|
Can you confirm the simple case we mentioned previously work or not? You can't keep jumping to your actual scenario without running the basic tests because the result of the basic test scenario would indicate where to look next.
|
|
Rank: Advanced Member Groups: Member
Joined: 12/14/2018 Posts: 31
|
Agree, below sample code with in Web API hosted on 64 bit azure app service is hanging in the line HtmlToPdf.ConvertHtml("test", doc); of code.
Code: C#
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertHtml("test", doc);
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,258
|
We asked you about standard MVC application, not Web API application. One thing at a time. Don't jump.
|
|