why unable to compress scanned PDF in ghostscript? - pdf

In older version 8.70 it was working but I had updated the ghostscript version 9.27 and now it's not compression the scanned pdf files. Can we have any other solution to compress pdf on linux server?
Below command I am using for the pdf compression
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dDownsampleColorImages=true -dPrinted=true -dColorImageResolution=100 -dNOPAUSE -dBATCH -sOutputFile=output.pdf input.pdf
Sample file
https://easyupload.io/fe64dt

Related

Compression of pdf using ghostscript removes font names

I'm trying to compress a pdf using ghostscript using following command gswin64c -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=output.pdf input.pdf
But if I then check the fonts using gswin64c -dPDFINFO -dNOPAUSE -dBATCH input.pdf and gswin64c -dPDFINFO -dNOPAUSE -dBATCH output.pdf
the fonts aren't loaded as before.
If I use pdf.js to analyse the pdf the fontname has gone from Helvetica to g_d36_f1 is there any flag I can use that preserves the font names?

How do I replace a page in a PDF with another page using Ghostscript?

I'm using Ghostscript 9.21 on Mac High Sierra ...
localhost:~ davea$ gs -version
GPL Ghostscript 9.21 (2017-03-16)
Copyright (C) 2017 Artifex Software, Inc. All rights reserved.
I have a PDF document with 4 pages. I would like to replace page 3 with another PDF file, pg3.pdf, consisting of one page. How do I do that using Ghostscript?
I wanted to achieve this in one go instead of having to create separate pdf files first. Here is what worked for me and may be helpful to someone:
gs -sDEVICE=pdfwrite -sOutputFile=final.pdf -dBATCH -dNOPAUSE -sPageList=1-2 yourPdfFile.pdf -sPageList=1 newPdfPage.pdf -sPageList=4 yourPdfFile.pdf
This should get the job done:
//get the first two pages
gs -sDEVICE=pdfwrite -sOutputFile=part1.pdf -dBATCH -dNOPAUSE -sPageList=1,2 yourPDFFile.pdf
//get the rest of the file
gs -sDEVICE=pdfwrite -sOutputFile=part2.pdf -dBATCH -dNOPAUSE -sPageList=4- yourPDFFile.pdf
//Merge files into one pdf
gs -sDEVICE=pdfwrite -sOutputFile=merge.pdf -dBATCH -dNOPAUSE part1.pdf pg3.pdf part2.pdf

Ghostscript command convert pdf into large JPGE File

I have a ghostscript command that converts a pdf into several JPG images (one for every page). The command arguments are as follows:
-q -dUseCropBox -dFirstPage=1 -dLastPage=1 -dBATCH -dDOINTERPOLATE -dNOPAUSE -dSAFER -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dPrinted=false -r250 -sDEVICE=jpeg -dJPEGQ=100 -sOutputFile=output.jpg input.pdf -c quit
The pdf size is 1.5mb but in the JPGE images it becomes huge (~15MB) with dimension 8829 *15551
if I change the resolution in the ghostscript command to -r150 the page size is correct but the image quality is very rastorized.
Is there another way to decrease the image size of the image without affecting the image quality?
Thanks

Converting PDF to PCL via Ghostscript only without colour?

We are trying to convert some PDF files into PCL files using Ghostscript.
The commandline we're using:
gswin32c -dBATCH -dNOPAUSE -sDEVICE=pxlcolor \
-f ..\examples\pu.pdf -sOutputFile=..\examples\pu.pcl
This generates a black&white PCL file.
Please help, what's wrong?

GhostScript removes images from some processed PDF files

I'm using this command with gs 9.01:
gs -q -dAutoRotatePages=/None -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -sOutputFile=out.pdf in.pdf in.pdfmarks
and on some processed files (out.pdf) I noticed that images are missing, although present in input file (in.pdf).
Why is this and how can I assure that images are retained after processing with gs?
1) Update to the current version, 9.04.
2) If you still experience problems, report a bug at http://bugs.ghostscript.com. You will need to attach a sample PDF file