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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Server side error when rendering pdf pages

Thread ID:





149004 Nov 11,2019 07:52 PM UTC Nov 15,2019 12:50 PM UTC ASP.NET Core - EJ 2 2
Tags: PDF Viewer
Nathan Nandi
Asked On November 11, 2019 07:52 PM UTC

I wrote a controller based on the example here: https://www.syncfusion.com/kb/10343/how-to-use-ej2-pdf-viewer-in-razor-pages, but adjusted the code for a web api controller. I have the following action (this.cache is an injected IMemoryCache):

        public IActionResult RenderPdfPages([FromBody] Dictionary<string, string> jsonObject)
            using (var pdfviewer = new PdfRenderer(this.cache))
                var jsonResult = pdfviewer.GetPage(jsonObject);
                return this.Content(JsonConvert.SerializeObject(jsonResult));

After a successful Load action is returned to the front end, the above method gets called with the following jsonObject parameter:


The jsonResult after GetPage is called is:

The given key '1' was not present in the dictionary.

While setting breakpoints in the code, I see that the memory cache does have the key that is provided in the jsonObject's hashId property with a value that is a syncfusion cache entry. So, there does not seem to be anything missing from the cache.

Do you have any more info about what the error could be describing?

Akshaya Arivoli [Syncfusion]
Replied On November 12, 2019 01:21 PM UTC

Hi Nathan, 

Thank you for contacting Syncfusion support. 

We can reproduce the reported issue with the provided details, we will analyze further on this and update you with more details on November 15th, 2019. 


Akshaya Arivoli [Syncfusion]
Replied On November 15, 2019 12:50 PM UTC

Hi Nathan, 

We have analyzed further on the reported behavior and found that loaded PDF document stream is removed from the PdfRenderer stream manager object if we initialize it in the ‘using’ keyword. In our architecture, we are rendering the pages in the PDF Viewer by on demand rendering method, if we initialize the PdfRenderer object in 'using' keyword and it will clear the loaded PDF document stream from the PdfRenderer stream manager object. So, on further processing for rendering or retrieving the annotation details from the loaded document and it's thrown the not found exception. We are maintaining the currently loaded document stream in our stream manager and it should in live to work further with that document. The stored document will be removed on unloading/closing that document. We can unload the PDF document manually by calling the unload() API available in PDF Viewer. Please find the below UG link for reference, 

We can resolve this by creating the PDF Viewer object without using keyword. We have created sample for the same and shared in the below location, 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon