EXTRACTPDFMARK(1)
β¨ EXTRACTPDFMARK(1) β¨
ok so real quick β this is the General Commands Manual page for extractpdfmark, and bestie, if you've ever watched Ghostscript eat your PDF bookmarks and page mode, this one's for you π
πΈ NAME πΈ
extractpdfmark β extract page mode and named destinations as PDFmark from PDF π
π¦ SYNOPSIS π¦
extractpdfmark file.pdf > file.ps
π DESCRIPTION π
This manual page documents briefly the extractpdfmark command. Not the whole saga, just the highlights β¨
So here's the vibe. When you create a PDF document using a TeX system, you may include many small PDF files in the main PDF file. And it is common β like, extremely common β for each of those files to use the same fonts. Same fonts, over and over, like everyone showed up to the party in the same outfit π
Now, if the small PDF files contain embedded font subsets, the TeX system includes them as-is in the main PDF. Which meansβ¦ several subsets of the same font end up embedded in the main PDF. And ngl, it is not possible to remove the duplicates since the subsets differ. So this vastly increases the size of the main PDF file. It's giving bloat. It's giving why-is-this-file-80MB. π
On the other hand π«Ά if the small PDF files contain embedded full font sets, the TeX system also includes all of them in the main PDF. This time, the main PDF contains duplicates of the same full sets of fonts. So Ghostscript can remove the duplicates π and this may considerably reduce the main PDF file's size. Iconic. Obsessed.
Note: Ghostscript 9.17 - 9.21 needs the -dPDFDontUseFontObjectNum commandline option for removing duplicate fonts. If you use Ghostscript 9.22+, you cannot use this "full set embedding" method since it cannot remove duplicate fonts. In this case, you can use the "not embedding" method as following. π
Finally β¨ if the small PDF files contain some fonts that are not embedded, the TeX system outputs the main PDF file with some fonts missing. In this case, Ghostscript can embed the necessary fonts. It can also significantly reduce the required disk size. slay π
Either way β every single way, bestie β when Ghostscript reads the main PDF produced by the TeX system and outputs the final PDF, it does not preserve PDF page-mode and named-destinations, etc. As a result, when you open the final PDF, it is not displayed correctly. Also, remote PDF links will not work. Tragic. Devastating. Not the main character ending we wanted. π
This program is able to extract the page mode and named destinations as PDFmark from PDF. By using this you can get the small PDF files that have preserved them. periodt π
π EXAMPLE π
$ extractpdfmark TeX-System-Outputted.pdf > Extracted-PDFmark.ps
$ gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite \
-dPDFDontUseFontObjectNum -dPrinted=false \
-sOutputFile=Final.pdf \
TeX-System-Outputted.pdf Extracted-PDFmark.ps
Note: Ghostscript 9.26+ needs the -dPrinted=false commandline option. Don't forget it, fr fr π
and that's the whole page, bestie π this one's from the General Commands Manual, dated January 26, 2019 β so go forth, extract those PDFmarks, and make Ghostscript behave πβπ¦
π¦ where this page comes from
- debian bookworm: extractpdfmark 1.1.1-1 Β· GPL-3.0-or-later
- debian trixie: extractpdfmark 1.1.1-1+b3 Β· GPL-3.0-or-later
- fedora 43: extractpdfmark 1.1.1-11.fc43 Β· GPL-3.0-or-later
- fedora 44: extractpdfmark 1.1.1-13.fc44 Β· GPL-3.0-or-later
- nixos 26.05: extractpdfmark 1.1.1
- nixpkgs unstable: extractpdfmark 1.1.1
- opensuse-leap 16.0: extractpdfmark 1.1.1-bp160.1.13 Β· GPL-3.0-or-later
- opensuse-leap 16.0: extractpdfmark 1.1.1-bp160.1.13 Β· GPL-3.0-or-later
- opensuse-leap 16.0: extractpdfmark 1.1.1-bp160.1.13 Β· GPL-3.0-or-later
- opensuse-leap 16.0: extractpdfmark 1.1.1-bp160.1.13 Β· GPL-3.0-or-later
- ubuntu jammy: extractpdfmark 1.1.0-1.2 Β· GPL-3.0-or-later
- ubuntu noble: extractpdfmark 1.1.1-1build2 Β· GPL-3.0-or-later
- ubuntu questing: extractpdfmark 1.1.1-1build4
- ubuntu resolute: extractpdfmark 1.1.1-1build6 Β· GPL-3.0-or-later
- ubuntu stonking: extractpdfmark 1.1.1-1build6 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms