Problems when Document Reference pointer does not exist

Hello!

I've been using the PDF Viewer module on a C# Core project for some time. Now that we're close to release, we've been encountering a couple of problems with the PDF Viewer, mainly when it comes to saving a Form within the database.

Typically, our workflow would be as follows:

  1. Serve a document that is stored server-side.
  2. User fills out any form fields as desired. So far, these forms do not contain any PDF validations or other logic.
  3. When User submits the form back to the server, the server performs a `pdfviewer.ExportFormFields()` function using the jsonObject that was sent by the user.
However, on this last step, instead of obtaining a Base-64 string as expected, we get the message "Document Reference pointer does not exist in the cache".

The PDF Viewer was built with the `IMemoryCache` similar to the solution provided in this forum post.

We've been attempting to replicate this issue on our development server, but so far have not been able to reproduce this error. Additionally, it is some users that are experiencing this issue: other users are able to  Is there some cache setting that is important to consider in order to prevent this issue?

Otherwise, is there any way to prevent the Document Reference to be deleted from the cache?

Thanks in advance for any guidance you're able to provide regarding this problem.

3 Replies 1 reply marked as answer

DM Dhivyabharathi Mohan Syncfusion Team March 5, 2021 12:10 PM UTC

Hi Radames, 
 
Thank you for contacting Syncfusion support. 
 
Please find the details, 
 
Query 
Details 
Serve a document that is stored server-side. 
 
 
we have created the sample for saving the PDF document on the server-side. Using download icon from the toolbar, we can use the below code snippet to save the document in server side. 
 
 
Controller code: 
 
 
public IActionResult Download([FromBody] Dictionary<string, string> jsonObject) 
        { 
            PdfRenderer pdfviewer = new PdfRenderer(); 
            string documentBase = pdfviewer.GetDocumentAsBase64(jsonObject); 
            string base64String = documentBase.Split("data:application/pdf;base64,")[1]; 
            if (base64String != null || base64String != string.Empty) 
            { 
                byte[] byteArray = Convert.FromBase64String(base64String); 
 
                MemoryStream ms = new MemoryStream(byteArray); 
                System.IO.File.WriteAllBytes(_hostingEnvironment.WebRootPath + @"/data/output.pdf", byteArray); 
            } 
            return Content(string.Empty); 
        } 
 
 
 
User fills out any form fields as desired. So far, these forms do not contain any PDF validations or other logic. 
 
 
In our PDF Viewer, we need to set the property EnableFormFieldsValidation as true to validate the form fields. We have an event ValidateFormFields to check whether all the fields are filled or not, before downloading the document. If any form field is non-fillable while downloading,  the validateFormFields event will gets triggered. We have shared the code snippet and sample for your reference.  
  
Code snippet: 
 
 
<ejs-pdfviewer id="pdfviewer1" serviceUrl="/api/PdfViewer" enableFormFieldsValidation="true" documentPath="HTTP Succinctly.pdf" downloadFileName="xyz.pdf" validateFormFields="validateFormFields"></ejs-pdfviewer> 
 
function validateFormFields(args) { 
        var fields = args.nonFillableFields; 
    } 
 
 
Sample: 
 
When User submits the form back to the server, the server performs a `pdfviewer.ExportFormFields()` function using the jsonObject that was sent by the user. 
However, on this last step, instead of obtaining a Base-64 string as expected, we get the message "Document Reference pointer does not exist in the cache". 
 
 
We were unable to reproduce ether reported issue. And we have shared the sample in which we tried to replicate the reported issue. 
 
Sample: 
 
 
Kindly try it and let us know, if you still have any concerns. 
 
 
We've been attempting to replicate this issue on our development server, but so far have not been able to reproduce this error. Additionally, it is some users that are experiencing this issue: other users are able to  Is there some cache setting that is important to consider in order to prevent this issue? 
 
We will store the document in the cache based on the hashid during the initial loading of the pdf file. Then on scrolling or navigating to that page we will send the hashid and required page number from the client-side and then we will retrieve the page details with the hashid on the server-side. So the cache is required for rendering the PDF pages in our PDF Viewer control 
 
 
Regards, 
Dhivya. 


Marked as answer

RA Radames Acosta April 8, 2021 04:17 PM UTC

Dear Dhivyabharathi,

Thanks for the prompt response! Apologies for not answering earlier.

I could verify if we were following the outlined steps, and have ensured all of them are followed accordingly. With the exception of form validations (we don't need that feature yet, but thanks for guiding me into how to implement it), everything else was found correct. Regarding this last part of your message, though:

"We will store the document in the cache based on the hashid during the initial loading of the pdf file. Then on scrolling or navigating to that page we will send the hashid and required page number from the client-side and then we will retrieve the page details with the hashid on the server-side. So the cache is required for rendering the PDF pages in our PDF Viewer control."

It helped us identify that the issue was in our end: the server was shutting down too fast, hence why the "document could not be found in the cache" when the user submitted the form. We could fix this by extending the amount of time the server is on and waiting for a response from the user.

Thanks much again for all the help and insight provided.


DM Dhivyabharathi Mohan Syncfusion Team April 9, 2021 10:57 AM UTC

Hi Radames, 
 
Thank you for the update. we will let you know if you need further assistance. 
 
Regards, 
Dhivya.

Loader.
Up arrow icon