We are experiencing a performance issue when opening the attached PDF document. We have shared both the sample and the PDF file for your reference.
Sample Steps:
1. Run the sample. Performance.zip
2. Download and Load the PDF document using the Choose File option. (https://drive.google.com/file/d/1lB7laAIjizgkghTZUXabk1Wvo7o5ZLAX/view?usp=drive_link)
3. Click the RenderPDFPage button.
4. Observe the console output for:
○ Image rendering time
○ Image conversion time
We need suggestions to improve performance.
Observations & Queries:
• The PDF document size is approximately 30 MB, but the generated image size ranges between 200 MB and 400 MB per page.
→ How can we reduce the generated image size?
• Currently, we render images using the tag.
→ Is there a way to obtain a Base64 string directly from PDFium instead of byte array?
• Is there any approach to reduce the image rendering time and improve overall performance?
We appreciate your guidance on optimizing this process.
Thanks for the response.
I am trying to render images inside an HTML <img> tag by converting PDFium output (byte arrays) into Base64. However, this approach is causing significant delays.
During analysis, I observed that PDFium returns image byte arrays of approximately 200–400 MB per page, even though the original PDF document size is only 30 MB. This results in heavy memory usage and slow Base64 conversion.
I have the following questions:
Any guidance, best practices, or examples would be greatly appreciated.