We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

pdfViewer looping while printing or downloading.

Dear all,
first of all. Thanks a lot for the pdf viewer and the previous explanation for the zoomfactor. Thanks that explanation i can use WebApi and AspNetCore. My setup is a remote service done in WebApi ASP.net mvc and the client is asp.net core. My problem is that while i click downloading or printing the component loops.
I use an owin setup with coors enabled. My controller is the following.
using System;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System.Web.Http;
using Syncfusion.EJ2.PdfViewer;
using System.Net;
using System.Net.Http;
using KarveReportService.Models;
using Microsoft.Web.Http;
using System.Threading.Tasks;
using System.Web.Http.Cors;
namespace ReportService.Controllers
{
public class SpecialReportDto
{
public string Document { get; set; }
}
///
/// ReportServiceController.
///
/// [EnableCors(origins: "*", headers: "*", methods: "*")]
[RoutePrefix("api/ReportService")]
public class ReportServiceController : ApiController
{
private MemoryStream reportStream;
///
/// Load asynchronously a dictionatry.
///
///
///
[AllowAnonymous]
[HttpPost]
[Route("Load")]
public async Task Load([FromBody] Dictionary jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
object jsonResult = new object();
if (jsonObject != null && jsonObject.ContainsKey("document"))
{
var reportDescriptor = new ReportDescriptor(jsonObject["document"]);
var reportService = new KarveReportService.Models.ReportService();
var reportStream = await reportService.GenerateReportStreamAsync(reportDescriptor);
var desc = Path.Combine(reportDescriptor.ReportPath, reportDescriptor.ReportFileName);
jsonResult = pdfviewer.Load(reportDescriptor.OutputFileName, jsonObject);
}
return Content(HttpStatusCode.OK, JsonConvert.SerializeObject(jsonResult));
}
[HttpPost]
[Route("Bookmarks")]
public IHttpActionResult Bookmarks([FromBody] Dictionary jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
var jsonResult = pdfviewer.GetBookmarks(jsonObject);
return Content(HttpStatusCode.OK, JsonConvert.SerializeObject(jsonResult));
}
[HttpPost]
[Route("RenderPdfPages")]
public IHttpActionResult RenderPdfPages([FromBody] Dictionary jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
if (jsonObject.ContainsKey("zoomFactor"))
{
jsonObject["zoomFactor"] = "1";
}
else
{
jsonObject.Add("zoomFactor", "1");
}
var jsonResult = pdfviewer.GetPage(jsonObject);
return Content(HttpStatusCode.OK, JsonConvert.SerializeObject(jsonResult));
}
[HttpPost]
[Route("RenderThumbnailImages")]
public IHttpActionResult RenderThumbnailImages([FromBody] Dictionary jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
object result = pdfviewer.GetThumbnailImages(jsonObject);
return Content(HttpStatusCode.OK,JsonConvert.SerializeObject(result));
}
[HttpPost]
[Route("Unload")]
public IHttpActionResult Unload([FromBody] Dictionary jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
pdfviewer.ClearCache(jsonObject);
return this.Content(HttpStatusCode.OK,"Document cache is cleared");
}
[HttpPost]
[Route("Download")]
public IHttpActionResult Download([FromBody] Dictionary jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject);
return Content(HttpStatusCode.OK, documentBase);
}
[HttpPost]
[Route("PrintImages")]
public IHttpActionResult PrintImages([FromBody] Dictionary jsonObject)
{
PdfRenderer pdfviewer = new PdfRenderer();
object pageImage = pdfviewer.GetPrintImage(jsonObject);
return Content(HttpStatusCode.OK, pageImage);
}
[Route("GetPlainText")]
private HttpResponseMessage GetPlainText(string pageImage)
{
var responseText = new HttpResponseMessage(HttpStatusCode.OK);
responseText.Content = new StringContent(pageImage, System.Text.Encoding.UTF8, "text/plain");
return responseText;
}
}
}
And the component instantation is the following:
enableBookmark="false"
serviceUrl="@Model.Report.ReportUri">
Looks likes i am missing something. In the post the json contains a base64 data field.
Best Regards,
Giorgio

5 Replies

RT Ramya Thirugnanam Syncfusion Team May 22, 2019 09:08 AM UTC

Hi Giorgio, 
 
Thank you for contacting Syncfusion support. 
 
We analyzed your query by adding the PDF Viewer control in the ASP.NET Core application and the service is created with ASP.NET MVC application. We are not able to reproduce the issue in downloading the PDF document. But we faced the below script error when the last page is to be printed in the PDF Viewer control. 
 
 
 
Please find the sample applications which we have used for reproducing the reported issue for your reference. 
 
 
 
Please confirm us whether the issue you faced in printing is same as the above screenshot. If not, please modify the above  applications to reproduce the reported issue or provide the screenshots of the script errors. Also please provide us more details for reproducing the issue. It will be helpful for us to analyze further and assist you better. 
 
Regards,  
Ramya T 



RT Ramya Thirugnanam Syncfusion Team May 22, 2019 11:34 AM UTC

Hi Giorgio, 
 
Sorry for the inconvenience caused. 
 
In the provided service sample, we have returned JSON stringified object instead of the object in the PrintImages action method in the provided server application. So the script error is thrown as given in the screenshot in the previous update while printing. Please include the below code example to fix the issue. 
 
    public object PrintImages(Dictionary<string, string> jsonObject) 
    { 
        PdfRenderer pdfviewer = new PdfRenderer(); 
        object pageImage = pdfviewer.GetPrintImage(jsonObject); 
        return pageImage; 
   } 
 
Please find the modified web service application below for your reference. 
 
 
We were unable to reproduce the reported looping issue. Could you please modify the provided applications to reproduce the reported issue or provide the screenshots of the script errors If the reported issue is still not reproduced? It will be helpful for us to analyze further and assist you better. 
 
Regards, 
Ramya T 



GI Giorgio May 24, 2019 12:18 PM UTC

Hello,

I will try the example. Meanwhile i upload my report service. It has a strict dependency on the db and on crystal report. as well you have a pdf. And a binary. Now i will download the example and give them a try..
Best Regards,
Giorgio

Attachment: ReportService_6dacd12e.zip


RT Ramya Thirugnanam Syncfusion Team May 27, 2019 12:00 PM UTC

Hi Giorgio,  
 
Thanks for providing details to validate the reported issue. 
 
We are validating the provided sample with Owin service configuration. We will get back to you with further details on May 29th 2019. 
 
Regards, 
Ramya T 



RT Ramya Thirugnanam Syncfusion Team May 29, 2019 11:44 AM UTC

Hi Giorgio 
We were unable to reproduce the reported issue due some issue after deploying the application.  A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates  
Regards,  
Ramya T  


Loader.
Live Chat Icon For mobile
Up arrow icon