Compression of pdf using ghostscript removes font names - pdf

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?

Related

why unable to compress scanned PDF in ghostscript?

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

can we convert PDF containing Embedded Fonts to NonEmbedded(standard fonts) PDF document using Ghostscript?

I have tried the below commands
$ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf inputwithembeddedType1.PDF
$ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dEmbedAllFonts=false -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf inputwithembeddedType1.PDF
In the first case the output is correct with AdobeReader but it is still embeddedfonts, and hence unable to parse into my application as a limitation of not supporting embedded PDF fonts.
The second command works and created a PDF file while not able to open in AdobeReader as well as my application.
Any help would be much appreciated. Thank you very much !
Thanks I got my answer by a little research, making use of dNoOutputFonts. This is working well for me
ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dNoOutputFonts -dQUIET -dBATCH -sOutputFile=output.pdf inputwithembeddedType1.PDF

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

Remove PDF margins while using PDFFitPage in GhostScript

I'm fitting a file with no margins (produced using a pdfcrop from a normal PDF file) to a given paper size using GhostScript:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dFIXEDMEDIA \
-dPDFFitPage -d -dBATCH -dQUIET -dNOPAUSE -dDEVICEWIDTHPOINTS=864 \
-dDEVICEHEIGHTPOINTS=612 -sOutputFile=$INPUT $OUTPUT
but the output has additional margins (I was cropping in order to get rid of them).
Is it possible to force GhostScript to produce output without these margins?
Without seeing your file I cannot be certain, however I suspect that all you have done is set a /CropBox in the PDF file. By default Ghostscript uses the /MediaBox which is probably unchanged.
Try setting -dUseCropBox