'Is there a way to apply background color to files while loading in iframe?

I am getting the pdf URL from an API which needs to be shown in an iframe. The pdf is getting loaded but it is taking the background color as black (probably the default browser color). Tried adding allowtransparency="true" style="background-color: Snow" but this applies to the iframe and not on the background of the file. Here's my code: <iframe src={urlOfPdfFile + "#toolbar=0"} width={'100%'} /> enter image description here



Solution 1:[1]

The background colour has nothing to do with the web page. It is usually hardcoded in the viewer Thus it can be white, grey, black or in my case when iFrame is using extension a gradient tricolor (red white and blue or when patriotic green white and gold) So you need to use the API of the PDF viewer. Or use a TamperMonkey.

enter image description here

Otherwise the default is most often the default white with security message for when you must right click to externalise the content of the frame to view it.

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1