9
votes
Extract even-numbered and odd-numbered pages of a PDF into two separate PDFs
pdftk is not Open Source any longer, unfortunately. (That is a long story.)
Plain gs engine can do it, though:
gs -sDEVICE=pdfwrite \
-sPageList=odd \
-sOutputFile=odd.pdf \...
8
votes
How can I fix the font problem of this pdf file?
I did some reading and some helpful posts on Stack Overflow (1, 2, 3) seem to suggest that the issue is with the specific fonts embedded in your PDF file. Your original file uses these fonts:
$ ...
7
votes
Overlay text in PDF via command line
For people that do not want to install a texlive distribution, you may prefer cpdf as explained here. However since cpdf has a strange license for commercial use, I tried to find an alternative. Here ...
5
votes
How do I insert a blank page into a PDF with ghostscript or pdftk?
If using pdfjam is an option:
pdfjam --outfile output.pdf input.pdf "-20,{},21-"
In pdfjam, {} inside range specifications is interpreted as a blank page, so this command inserts a blank ...
5
votes
How do I insert a blank page into a PDF with ghostscript or pdftk?
For anyone just looking to add a single blank page to the end of a PDF, I used the already linked question How do I create a blank PDF from the command line? to create a blank.pdf file and merge it ...
4
votes
How to stop Ghostscript from adding "Producer" metadata to PDF files
It seems that it is a deliberate choice for Ghostscript to not allow you to
set the DOCINFO /Producer key anymore. See
this
commit (here's on GitHub).
The Producer of the output really is the ...
3
votes
Accepted
"Place" Letter Sized PDF to Larger pdf at specific position
pdfjam, a tool that comes in TeX distributions like Texlive, will do the trick. The command will be
pdfjam -o cover.pdf --papersize '{17.25in,11.25in}' --noautoscale true --nup 2x1 cover-page.pdf '{},...
3
votes
3
votes
Extract even-numbered and odd-numbered pages of a PDF into two separate PDFs
You can use qpdf
qpdf --empty --pages input.pdf 1-z:even -- even.pdf
qpdf --empty --pages input.pdf 1-z:odd -- odd.pdf
2
votes
How to convert a color pdf to black-white?
I get reliable results cleaning up scanned pdf's to good contrast with this script;
#!/bin/bash
#
# $ sudo apt install poppler-utils img2pdf pdftk imagemagick
#
# Output is still greyscale, but lots ...
2
votes
Can't print to PDF using cups-pdf; used to work, now "failed to set file mode" printing as non-root
Having Referred to the following post:
https://ubuntuforums.org/showthread.php?t=1975881
After many research, in the end I found my problem was the permission of the folder /var/tmp/, it was 755 (...
2
votes
Accepted
Convert pdf font colors to monochrome black
Option 1:
convert -monochrome in.pdf out.pdf
Option 2:
You can still download Ghostscript 9.07
https://ghostscript.com/Ghostscript_9.07.html
Compile it from source and make install the result.
In ...
2
votes
Accepted
What is this GhostScript error? “/undefined in /BXlevel”
I'm noticing that you are using a very old GhostScript implementation. The error was reported to the GhostScript bug database in 2006 as bug #689876 (for releases 8.54 and 8.62) and should be fixed ...
1
vote
How can you compress images in a PDF (via a GUI, not batch or CLI util)?
Following are some GUI tools should be able to do what you want:
PDF Tricks
Qpdf Tools: Uses Ghostscript and QPDF.
Avoid importing and exporting with tools that were not intended to work ...
1
vote
Cannot open X display `(null)'. **** Unable to open the initial device, quitting
Apparently either your Windows 10 system does not have an "X11 server" software that could receive and display graphics data from X11 GUI applications, or if you have one set up, your SSH ...
1
vote
Accepted
How to scale down PDF file (in pixels and in cm)?
It worked with
gs -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dDEVICEWIDTHPOINTS=1280 -dPDFFitPage -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf in.pdf
which sets the size in cm to A4 ...
1
vote
methods of PDF compression
I assume that the size difference is related to ABBY using some commercial magic to be smart about image compression
Don't assume, investigate. The PDF format is well-documented, read up on the ...
1
vote
How to convert only the first page of a PDF to a JPG with Ghostscript
The answer (provided by @Freddy) was available in the online documentation:
-sPageList=1
1
vote
Close ghostscript without "-c quit" or -dBATCH
Your trap on EXIT is not specifically executed when you close the terminal window or press Ctrl+C, it is executed when then shell exits.
Closing the terminal will kill the shell running in the ...
1
vote
Accepted
Using Ghostscript to extract every nth page from PDF
Does this help at all?
#!/bin/bash
function getChunk {
#extract a page range
gs -q -dNOPAUSE -sDEVICE=pdfwrite -sPageList=$1-$2 -o ${3%%.*}_$(printf %04d $4).pdf $3
}
for file in *.pdf; do
...
1
vote
Error while trying to compress pdf using ghostscript recursively via loop
The Problem
By default, find performs the -print action:
-print
True; print the full file name on the standard output, followed by a newline.
The "full file name" means that you'll see the ...
1
vote
Accepted
Trouble installing GS from source
To have the compiler pick up math.h, I added -std=c99 to LCMS2_CFLAGS in the main Makefile once configure finished:
LCMS2_CFLAGS=-DSHARE_LCMS=$(SHARE_LCMS) -std=c99
1
vote
Accepted
Finding the size (in points) of the descender of a font in Ghostscript / Postscript?
If you want to draw the line just under the descenders of a given string you can use pathbbox as in the link provided by ridgy in the comments to your question, but if you want a constant distance ...
1
vote
How to tell libgs to use another freetype implementation?
One solution is to set LD_PRELOAD to original libfreetype.so.
Another one is to recompile infinality with latest libfreetype (2.8.1).
1
vote
Splitting a PDF file with Ghostscript results in one extra blank page
I've encountered the same behavior. After digging into the documentation it appears that this is a known issue:
Note, however that the one page per file feature may not supported by all devices. ...
1
vote
How can I convert a scanned PDF with OCRed text to one without OCRed text?
While
gs -o output.pdf -sDEVICE=pdfwrite -dFILTERTEXT input.pdf
is now a simple solution, there can be an issue with embedded jbig2 images that are recompiled by gs and increase in size.
Below are ...
1
vote
Can't print to PDF using cups-pdf; used to work, now "failed to set file mode" printing as non-root
My users' home directories are in /local/home, so I had to change the line
@{HOMEDIRS}=/home/ /local/home/
in /etc/apparmor.d/tunables/home.
Then restart apparmor with
sudo service apparmor restart
1
vote
How to convert a color pdf to black-white?
There are many great answers above. I took one of the answers above and added some human interfacing to it. Maybe someone will find it useful.
#!/bin/bash
pdf2Gray()
{
if [ -z "$1" ]; then
...
1
vote
Install Ghostscript v 9.05 (or newer) on CentOS
In CentOS 8 there is an easier way to do this installation:
dnf --enablerepo=PowerTools install ghostscript
1
vote
How to convert a pdf to 4-up in landscape mode (ideally using ghostscript)?
Here is an approach with LaTeX. It puts 6 4"×6" postcards onto a 11"×17" sheet of paper including rotation to fit the two on the side.
This could be improved by adding cut marks.
\...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
ghostscript × 70pdf × 44
pdftk × 10
printing × 7
imagemagick × 7
postscript × 7
linux × 6
fonts × 5
cups × 5
bash × 4
conversion × 3
debian × 2
ubuntu × 2
shell × 2
command-line × 2
find × 2
x11 × 2
pipe × 2
printer × 2
evince × 2
shell-script × 1
centos × 1
terminal × 1
apt × 1
software-installation × 1