windows - Changing the text and background color of a PDF file -


i'd change background color , text color programmatically in pdf documents they're nicer read @ night (kinda in adobe reader: edit -> preferences -> accessibility -> replace document colors).

is there command line tool or api windows can that?

so far haven't found any. it's ok if needs save newly colored pdf new file.

there no way directly, no (free software or gratis) tool i'm aware of. (because in general case, you'll have change all colors of pdf pages, not background alone, can still have contrast , color differences.)

what describe adobe reader not change pdf file itself, changes way application renders pages (by inverting colors, or similar). pdf remains same during , after viewing it.

however, might able achieve similar thing applying suitable icc color profile input pdf , produce, of (a recent version of) ghostscript, new output pdf this.

the question remain: is "suitable" icc color profil purpose??


i've shortly considered apply gray-ish background pdf of pdftk ... background ... command line. make or many pdfs unreadable. (a black background surely make unreadable, because text black , remain so.)

to create pdf page (a4 size) serve gray background, use ghostscript: gs -o gray.pdf -sdevice=pdfwrite -g5950x8420 -c ".8 setgray 0 0 595 842 rectfill showpage".

then apply original pdf (a4): pdftk original.pdf background gray.pdf output orig-with-backgr.pdf.

note, change background of these pages (or areas of pages), original background transparent, as most text-based pdfs are. not work pages or areas background opaque white or color.)


you can achieve permanent color change (inverse colors) quite of imagemagick. @ same time munch , make mincemeat of nice vector pdfs, converting them complete-raster image pages: convert nice.pdf -alpha off -invert inverted-colors-ugly-raster.pdf.


finally, here rather unreliable way accomplish inverting of colors of ghostscript. sets colortransfer function output pdf file:

gs -o output.pdf     \    -sdevice=pdfwrite \    -c "{1 exch sub}{1 exch sub}{1 exch sub}{1 exch sub} setcolortransfer" \    -f input.pdf 

it unreliable, because not every pdf viewer honor setting. i've tested few times in past...

these viewers do show inverted colors:

  1. adobe reader
  2. adobe acrobat
  3. gv
  4. ghostscript/gs
  5. chrome's native pdf renderer ('pdfium')

these ones don't show inverted colors:

  1. chrome pdf.js
  2. firefox pdf.js
  3. zathura
  4. mupdf

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -