>1) Could I rasterize everything in this PDF except for text using
>Or even better only rasterize gradients?
No. However you *could* use the ps2write device to convert into PostScript,
then use the pdfwrite device to convert the PostScritp back into PDF.
Shading dictionaries are not supported in PostScript level 2, and so the
shadings will be rendered at the resolution specified on the command line.
When converted back to PDF the images will be retained as images.
Note that some other things are also not supported in PostScript level 2
and will likewise be converted. Chiefly CIDFonts will be converted into
bitmap type 3 fonts.
I'm doubtful that a series of gradient fills could really occupy as much
space as you seem to suggest. Possibly these are in fact clipped to a
complex path ? In this case conversion to an image will not help, since the
image would still need to be clipped to the path.
>2) Can I get an output from Ghostscript (or any other linux terminal
>tool) telling me how many vectors (shapes) are in any given PDF file
>and I could use that information to decide if to rasterize or not?
You could write your own Ghostscript device to do this, in fact you would
have to, since its unclear to me what you would consider a 'vector' or
'shape'. I don't know of any tool on any platform that would do anything
Similarly you could use MuPDF (writing your own code), but I'm less
familiar with what would need to be done here.