Change the color of text and background in a PDF file

I would like to change the background color and text color programmatically in PDF documents so that they are better read at night (as in Adobe Reader: Edit → Preferences → Accessibility → Replace Document Colors).

Is there any good command line tool or API for Windows that can do this?

So far I have not found them. This is normal if you want to save the new color PDF to a new file.

+4
source share
4 answers

It is not possible to do this directly without using the (free software or free) tool that I know of. (Because in the general case, you will have to change the colors all on the PDF pages, not just one background, so you can still have some differences in contrasts and colors.)

What you describe for Adobe Reader does not change the PDF file itself, it changes the way the pages are displayed (by inverting colors or the like). PDF remains unchanged during and after viewing.

However, you could achieve a similar thing by applying a suitable ICC color profile to the input PDF file and using (with the latest version) Ghostscript a new PDF file.

The question remains: which IS is the “appropriate” color ICC profile for your purpose?


PDF pdftk ... background .... , , PDF . ( , , , .)

PDF ( A4), , Ghostscript: gs -o gray.pdf -sDEVICE=pdfwrite -g5950x8420 -c ".8 setgray 0 0 595 842 rectfill showpage". >

PDF (A4): pdftk original.pdf background gray.pdf output orig-with-backgr.pdf.

. ( ), , PDF . , .)


( ) ImageMagick. PDF , : convert nice.pdf -alpha off -invert inverted-colors-ugly-raster.pdf.


, Ghostscript. colortransfer PDF:

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

, PDF . ...

SHOW :

  • Adobe Reader
  • Adobe Acrobat
  • ..
  • Ghostscript/
  • PDF- Chrome ('pdfium')

:

  • Chrome PDF.js
  • Firefox PDF.js
  • Zathura
  • MuPDF
+2

OP PDF, , PDF, Acrobat, ...

MuPDF: MuPDF - PDF ( ). i , . MuPDF Windows ( iOS, Android, OSX, Linux). ( , Ghostscript).

MuPDF : "" () "" ()

85qcL.pngA5KWQ.png

SumatraPDF: PDF Windows. PDF MuPDF. . . w , . ( , , , , .) -invert-colors .

Zathura: PDF Linux OSX, Vim. ctrl + r . , - ( a, , MuPDF). , Windows.

Evince: Gnome PDF, Linux, OSX Windows. ; ctrl + i.

XPDF: XPDF - PDF Unix + Linux ( , Windows - , Cygwin). : xpdf -rv -papercolor "#333333" file.pdf (-rv , -papercolor - [ ]).

+3

API, . Adobe Acrobat (, Adobe Reader , Reader ), .

- Enfocus PitStop PDF Adobe Acrobat. , , , . , ( ) ( ), Acrobat.

, ( ), , , .

, : , PDF , Acrobat . , PDF , , . Adobe Acrobat , , - , , .

, . , , :)

+2
  • Install nodejs.
  • npm i -g serve
  • In the directory with the launch of pdfs: serve
  • Open http: // localhost: 5000 in Chrome and click on some file.
  • Install Chrome Dark Reader Extension
  • Dark Reader > Toggle localhost:5000

enter image description here

+1
source

All Articles