- Home
- Forum
- ASP.NET Core - EJ 2
- Server side error when rendering pdf pages
Server side error when rendering pdf pages
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):
[HttpPost]
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:
{"xCoordinate":"0","yCoordinate":"0","viwePortWidth":"1583","viewportHeight":"640","pageNumber":"0","hashId":"\b['?>?t???????v?","tilecount":"1","zoomFactor":"1","action":"RenderPdfPages","uniqueId":"Sync_PdfViewer_8ae71a9c-18da-4931-0863-405f0f8cc5af","documentId":"xxxxxx.pdf"}
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?
SIGN IN To post a reply.
2 Replies
AA
Akshaya Arivoli
Syncfusion Team
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.
Regards,
Akshaya
AA
Akshaya Arivoli
Syncfusion Team
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,
Getting Started UG link : https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/getting-started/
Regards,
Akshaya
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
-
NN Nathan Nandi
- Nov 11, 2019 07:52 PM UTC
- Nov 15, 2019 12:50 PM UTC