Re: Converting text from blue to black in pdf.

William Bader <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.devel
Message-ID <[email protected]>
> Date: Wed, 4 Mar 2015 15:28:17 -0500
> From: [email protected]
> To: [email protected]
> Subject: [gs-devel] Converting text from blue to black in pdf.
> 
> I have tried various games listed on the internet
> but either the text ends up in a shade of gray or
> it gets seriously distorted. Just to complicate
> things there are plenty of illos where
> conversion to grayscale is appropriate. Any
> suggestions?

This is a bit hacky, but if you can get the postscript, you could redefine the operators to set color.
I have attached an example that converts from color to grayscale.
To convert to black, before calling setgray, if the graylevel is < 1 (or maybe < 0.8 to avoid changing text on a light background to black box), set it to 0.
/toblack { 0.8 lt { 0 } { 1 } ifelse } bind def
Redefining operators this way should change most text and vector-based drawing but will probably not affect most bitmapped images.
If you only want to modify text, and you are lucky that text is not vectorized, you might be able to redefine show (and possibly xshow, yshow and xyshow) to modify the color, print the string, and then restore the color.
William

_______________________________________________
gs-devel mailing list
[email protected]
http://ghostscript.com/cgi-bin/mailman/listinfo/gs-devel
spgbegin.txt (text/plain, 891 B)
% Convert some color operators to grayscale

/setrgbcolor {
	0.114 mul	% convert blue
	exch 		% place green on top of stack
	0.587 mul	% convert green
	add		% add green to total
	exch 		% place red on top of stack
	0.299 mul	% convert red
	add		% add red to total
	setgray
} bind def

/setcmykcolor {
	exch		% place yellow on top of stack
	0.114 mul	% convert yellow
	add		% add yellow to total
	exch 		% place magenta on top of stack
	0.587 mul	% convert magenta
	add		% add magenta to total
	exch 		% place cyan on top of stack
	0.299 mul	% convert cyan
	add		% add cyan to total
	1 exch sub	% convert from black to white
	setgray
} bind def

/sethsbcolor {
	pop		% ignore brightness
	pop		% ignore saturation
	setgray		% use hue
} bind def

/setcustomcolor
{
	exch aload pop pop 4{4 index mul 4 1 roll}repeat 5 -1 roll pop	% convert to cmyk
	setcmykcolor							% use our cmyk
} bind def
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.