Pdfviewer load method error

Hi team,


I have a pdfviewer on our angular ui and load controller in .net6 api. i am trying to implement redis for load balancing environment but i am getting an "failed to write" 

after the load method is called, i see an entry in the redis db so i dont think error is in the redis setup


heres the load method code"


try
{
Dictionary<string, string> jsonObject = json.ToDictionary(x => x.Key, x => x.Value.ToString());


//Initialize the PDF viewer object with memory cache object
PdfRenderer pdfviewer = new PdfRenderer();

Stream stream = new MemoryStream();
object jsonResult = new object();

if (jsonObject != null && jsonObject.ContainsKey("document"))
{
Log.Info($"Loading document for contract id: {jsonObject["document"]}");
var ogStream = DownloadFromServer(jsonObject["document"]);
ogStream.CopyTo(stream);
stream.Position = 0;
}

pdfviewer.CacheManager = new CacheManagerService(RedisConnectionString, 0);
jsonResult = pdfviewer.Load(stream, jsonObject);
return Content(JsonConvert.SerializeObject(jsonResult));
}
catch (Exception ex)
{
return this.BadRequest(ex.Message);
}



screenshot of error:

Image_2184_1737500554038  

please let me know how to proceed


11 Replies

SK Sathiyaseelan Kannigaraj Syncfusion Team January 22, 2025 04:02 PM UTC

Hi Rangita Rajakumar,

Thank you for reaching out to us. We have provided a sample that includes a Redis cache in the service. Please check if the issue occurs in the provided sample. If you are still experiencing any issues, kindly share a demo sample replicating the problem so that we can investigate and provide a solution.


Client Sample


Server Sample


Replication Steps
:

  1. Run the server sample.
  2. Run the client sample.

 

When using server-side components, delays may occur due to server communication for loading and rendering pages. To overcome this, we have introduced a standalone PDF viewer that performs rendering on the client side. For more details, please refer to the documentation on the standalone PDF viewer.

Documentation on Standalone PDF Viewer

Demo on Standalone PDF Viewer


Regards,
Sathiyaseelan K



RR Rangita Rajakumar January 22, 2025 06:38 PM UTC

Hi Sathiyaseelan, we are using server backed pdfviewer 



SK Sathiyaseelan Kannigaraj Syncfusion Team January 23, 2025 02:20 PM UTC

Hi Rangita Rajakumar,

The sample we provided features a server-backed PDF viewer component with Angular on the client side and ASP.NET Core as the service. Please review the sample to confirm whether the issue persists. If you continue to encounter any issues, kindly provide a sample or demo video to help replicate the problem.


Regards,
Sathiyaseelan K



RR Rangita Rajakumar January 23, 2025 09:35 PM UTC

It is working now but its not working for documents more than 700 pages. is there anything else we need to do at the redis infrastructure level?



RR Rangita Rajakumar January 23, 2025 09:45 PM UTC

is there any limitation on how many pages can be loaded using redis?



SK Sathiyaseelan Kannigaraj Syncfusion Team January 24, 2025 02:08 PM UTC

Hi Rangita Rajakumar,

Thank you for the update. The data transfer for Redis cache depends on the package you are using. If you are using the premium package, the data transfer will be seamless, with no exceptions thrown. Please verify whether the Standalone PDF Viewer component we recommended meets your requirements. For your reference, we have included the documentation and a sample once again.

Documentation on Standalone PDF Viewer

Sample on Standalone PDF Viewer
 


Regards,
Sathiyaseelan K



RR Rangita Rajakumar January 28, 2025 11:20 PM UTC

Yes this does meet the requirements but documents more than 1000 pages are not loading. Is the premium package you are referring to is the syncfusion package, or redis package? 


these are the packages im using. 

<PackageReference Include="StackExchange.Redis" Version="2.8.24" />
<PackageReference Include="Syncfusion.EJ2.PdfViewer.AspNet.Core" Version="27.2.2" />
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="27.2.2" />
<PackageReference Include="Syncfusion.Pdf.Net.Core" Version="27.2.2" />

anything else is needed?



RR Rangita Rajakumar January 28, 2025 11:52 PM UTC

Also, is it possible to only render selected pages? 


like if we want the user to enter page numbers like 1-5 in the ui and we render only those pages from the ui?



SK Sathiyaseelan Kannigaraj Syncfusion Team January 29, 2025 02:28 PM UTC

Hi Rangita Rajakumar,

Thank you for the update. The premium package we referred to is for using the Redis package. Additionally, please confirm whether your requirement is to initially load the first five pages of the PDF and then load the remaining pages on demand. If this is the case, you can achieve it using the initialRenderPages property to specify the number of pages to render during the initial load.

Documentation on initialRenderPages
 


Regards,
Sathiyaseelan K



RR Rangita Rajakumar January 29, 2025 10:48 PM UTC

I tried using the initialRenderPages property but the viewer still loads all the pages at once 

Image_2239_1738190839574


initialRender is set to 10


we ideally want to load the entire document which sometimes can be upto 2000 pages but since the pdfviewer is unable to load it all the same time, we want to explore the option of loading pages in batch, what is a good approach for this ?



SK Sathiyaseelan Kannigaraj Syncfusion Team January 30, 2025 01:10 PM UTC

Hi Rangita Rajakumar,

Thank you for the update. By default, the PDF Viewer component renders only the first two pages of the PDF, with the remaining pages loading on demand. The provided property allows increasing the initial page rendering count.


Please confirm whether your requirement is to increase the initial page rendering count or to load a specific number of pages first and then fetch the remaining pages upon request from the customer. If your requirement is this, it can be achieved using the PDF library to load only the required pages while removing the remaining ones on the server side before displaying the PDF in the viewer. Kindly confirm your requirement.


Regards,
Sathiyaseelan K


Loader.
Up arrow icon