How do I make use of a command that removes raster images from a PDF

I have a PDF, in it is raster image and SVGs, I want to keep the SVG and remove the raster image (that raster image appears in every page of the PDF, and the PDF is over 600 pages). After some researching, I found the following code can do the job:

sed-4.7-x64.exe -i "/<defs>/,/<\/defs>/d" MadinaMushaf_compressed.pdf

But the thing is, I don’t know what to do with this code. Where do I put it? Do I need to download any application before using it? I have Windows 10 and Windows 7.

“MadinaMushaf_compressed.pdf” is the name of the PDF that I want to remove the raster image from.

Hi @kutada

Based on what’s coming after it, sed-4.7-x64.exe is referring to GNU sed. If you’re on Linux, you might already have it installed. If you’re not on Linux, you may need to install it before hand.

As to whether running sed with those options will do what you want, I couldn’t say. :slight_smile:

I downloaded GNU and I got this:
sedtt ![sedtt|606x256]

So what should I do with it now?

If you have windows 10, i recommend WSL (windows subsystem for Linux), which is officially supported by Microsoft.

the latest update of GnuWin32 was in 2010, in software years, that is old.

i also recommend investing time in understanding what Linux and WSL are, and what the difference is.

1 Like

the thing is - I only need it to remove the raster images in this pdf,, and I will probably not use sed again

Then you should look into a windows tool perhaps? Then you make life easier for yourself.

every time there’s I have a problem to solve on windows and I google for a solution, there’s never something saying what needs to be done instead there’ll be an executable complete with GUI for the tiniest tasks like syncing the clock on boot

makes me look around for someone to blame for the situation, clearly someone needs to get shot

@kutada there’s probably a file in your bin directory named sed or sed.exe, that’s what you would run, with those arguments. but since you’re running something that you … well, don’t even know how to run, don’t be too surprised if it doesn’t do anything resembling what you want

For example, it would not correctly deal with:


It would leave the opening svg tag but not the closing one.

It would match on <defs> but not on <defs > so that would lead to skipping or if it’s the closing one that doesn’t match exactly then everything gets deleted from that point because the closing tag is never found

There may be 600 pages, but there might not be all that many defs tags. You’d want to inspect it anyway to figure out what you’re doing so grab a text editor.