How to Change the Background Color During PDF View Rendering?

Hello everyone,


I've implemented a night mode for my application, where I've changed the background color of PDFs to black. However, when the PDF has many pages and I scroll through it, the PDF Viewer renders the pages with a white background, which looks quite jarring. Is there any available API or method to modify the background color during PDF rendering? Any help would be greatly appreciated.


Thank you!


6 Replies

MS Manigandan Shanmugam Syncfusion Team July 3, 2023 01:52 PM UTC

Rhyme, As per the provided details, we come to know that you have changed the background color of the pages in the PDF document. Usually PDF document does not have background property for the pages in it, that’s why every PDF viewer application shows the PDF pages in the white color ,this is the default behavior. Can you please provide the document which you have changed the background color, it will be helpful for us to reproduce and analysis on this.



RH Rhyme replied to Manigandan Shanmugam July 4, 2023 05:42 AM UTC

Hello Manigandan,

I would be happy to provide you with the relevant PDF. To make it easier for you to test, I have changed its background color to yellow. When you open it in PdfViewer and quickly scroll through it, the background color will change from yellow to white and then back to yellow again.



Attachment: 100_Pages_background_d765ffc0.zip


MS Manigandan Shanmugam Syncfusion Team July 4, 2023 11:43 AM UTC

Rhyme, As we mentioned in the previous update, Pdf pages have no property for background color, so all viewer application will display PDF pages as white before rendering. You can also check that behavior with Google Chrome and Microsoft Edge. Additionally, there is no API to alter the background color before rendering. However, we are looking into possible workarounds to full fill your requirement. We will analyze and provide further details on July 6, 2023.



KG Krithika Ganesan Syncfusion Team July 6, 2023 02:40 PM UTC

Rhyme, we have checked the possibility to achieve your requirement to render different page color from sample. But there is no option to set background color. All other viewer application will also display PDF pages as white before its render.  It is the default behavior which you can also check with Google Chrome and Microsoft Edge. So it is not possible to change the page color before its render. 



RH Rhyme replied to Krithika Ganesan July 6, 2023 05:03 PM UTC

I see, thanks for your positive help



SS Swetha Srikumar Syncfusion Team July 7, 2023 06:32 AM UTC

Most welcome.


Loader.
Up arrow icon