Can PDF render one of 2 different objects based on device color capabilities?

StackOverflow https://stackoverflow.com/questions/21991007

  •  15-10-2022
  •  | 
  •  

Pregunta

We have an institutional logo, one design for color, and a different design for bi-level (B&W) renders. I have combined these two designs into one Encapsulated PostScript (EPS) file so that the proper design is selected at render-time depending on the color capabilities of the device.

Unfortunately, this functionality doesn't transfer when the graphic is translated to PDF. Is it possible to create a single PDF document that can display the color version of the logo when printed on a full-color device, and use the proper bi-level logo when printed on a B&W printer? (Our communications department insists that our logo should not be gray-scaled.)

I spent the weekend reading the PDF Reference, but I could not find a way to test render device capabilities from within the document, or conditionally execute sets of drawing primitives. Did I miss something?

Addendum:

The PostScript code that implements this looks like this:

systemdict /currentpagedevice known       % PostScript Level 2 test
    { currentpagedevice 
      /ProcessColorModel get 
      /DeviceGray ne     % pushes TRUE on stack if color
    }
    { systemdict /processcolors known }   % PostScript Level 1 punt
  ifelse
    { color_logo }                        % True: Draw full-color design
    { bilevel_logo }                      % False: Draw B&W design
  ifelse

I'm looking for a PDF equivalent, if such a thing is possible.

¿Fue útil?

Solución

I don't know of any proven solution to your problem, but you might want to try and use JavaScript™ for Acrobat® API.

Using JavaScript, it might be possible to change background images of buttons before document is printed. Or to change visibility of Optional Content Groups.

The following structures in the API might be of some interest to you:

  • Doc/WillPrint event
  • PrintParams object
  • Annotation object
  • OCG and it's properties

You can embed Javascript in a PDF using Acrobat Professional and a number of 3rd-party tools and libraries.

Please note, that most probably no PDF viewer except Adobe Reader supports full JavaScript API.

EDIT:

Another possibility is to embed Postscript directly in your PDF. There are PostScript XObjects for that.

Unfortunately, such objects might be unsupported or not fully supported in most viewers. Adobe Community forum has a thread about embedding of Postscript in PDF.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top