How to **remove** (not extract) all attachment from a pdf on linux with some open source software?

Could not find how to do it with qpdf or pdftk or even a gui tool.

Edit: Solution pdftk A=oldpdf.pdf cat A output newpdf.pdf This removes all metadata and also the attachments.

40 points · 11 comments · view on lemmy.world

11 Comments

kleiner_zeh@kbin.social · 5 pts · 3y

https://stackoverflow.com/questions/20676707/remove-delete-all-images-from-a-pdf-using-ghostscript-or-imagemagick

gs -o noimage.pdf -sDEVICE=pdfwrite -dFILTERIMAGE input.pdf

can't test it right now though.

davidgro@lemmy.world · 2 pts · 3y (1 reply)

Just a guess, but can LibreOffice open, edit, then save as (or at least print to) PDF?

qaz@lemmy.world · 2 pts · 3y

LibreOffice Draw can do that but you have to make sure the font and margins are right or else the formatting gets messed up.

garam@lemmy.my.id · 2 pts · 3y

Code Industry Master PDF does use open source tools. Sadly source code only available for paid user. 😂

beejjorgensen@lemmy.sdf.org · 2 pts · 3y

Slightly shorter:

pdftk old.pdf cat output new.pdf

rambos@lemmy.world · 2 pts · 3y (1 reply)

Im interested what people recommend. If you dont find any, what about just printing to another pdf file? Wouldnt that remove attachments?

antihero@lemm.ee · 2 pts · 3y

I found much easier solution, pdftk A=oldpdf.pdf cat A output newpdf.pdf. This removes all metadata and also the attachments.

Schorsch@feddit.de · 1 pts · 3y (1 reply)

You might try printing the PDF as a PDF.

antihero@lemm.ee · 1 pts · 3y

That worked but it removed bookmarks. I added solution to the post.

sin_free_for_00_days@lemmy.one · -1 pts · 3y (1 reply)

pdfimages is what you want, I believe. It's in the poppler-utils package in Debian.

antihero@lemm.ee · 4 pts · 3y

Sorry, but that is for image extraction.