Iducool
Iducool

Reputation: 3653

How to know the background color of Pdf

Sometimes pdf might have a transparent background. And In my application I have given a option to choose background. So, in case of pdf with transparent background and background color black all things becomes black black so, any way to check or any key inside dictionary of pdf page that can help me? Any help will appreciated.

Upvotes: 0

Views: 1708

Answers (1)

Swapnil Luktuke
Swapnil Luktuke

Reputation: 10475

The easiest solution for you would be to remove black color from available background colors.

Generally, all pdf pages have transparent background and the white background color is set by the viewer application. It is possible to set a background color for each page. You can read all about it in Page Group under Transparency section of the PDF Reference. It is also possible to show a background color for a page by setting 'BoxColorInfo' dictionary in the page dictionary with appropriate values.

But I am not sure what you can achieve by knowing what color a page background is, since black background is going to be a problem for PDFs with transparent pages anyways.

EDIT: Following is the paragraph from PDFReference i was trying to point you to:

Ordinarily, the page is imposed directly on an output medium, such as paper or a display screen. The page group is treated as an isolated group, whose results are then composited with a backdrop color appropriate for the medium. The backdrop is nominally white, although varying according to the actual properties of the medium. However, some applications may choose to provide a different backdrop, such as a checkerboard or grid to aid in visualizing the effects of transparency in the artwork.

It says that most PDFs would have a transparent and it is your application which shows the background color. Hope this helps.

Upvotes: 2

Related Questions