ghostscript pdf to postscript conversion taking long time - pdf

I am trying to convert 1000 pages PDF document to postscript file using the below command.
gswin32c.exe -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile=out.ps -f input.pdf
It takes 5 mins to convert, but in real-time, I will have more number of pages than this. I have tried with 30k pages pdf to convert ps using the same command. It takes 45mins.
After search in stack overflow, I have tried the below options of reducing resolution, set buffer memory, threading options, and all. Nothing worked. PF command below.
gswin32c.exe -q -r300 -dSAFER -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile=out.ps -dNumRenderingThreads=8 -dBufferSpace=2000000000 -f input.pdf
dCompressEntireFile option also not helps. Please, anyone, suggest improving the performance of ps conversion with Ghostscript.

Related

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

best solution for sending fax in asterisk

I want to write a script for sending a fax with Asterisk,
but many faxes have an error when sending.
I use Spandsp for Asterisk and I use gs for converting PDF to TIFF.
I think it may be a problem of converting PDF to TIFF.
I very try to convert's command for this, such as:
gs -q -sDEVICE=tiffg3 -dNOPAUSE -dBATCH -sOutputFile=Sample.pdf.tif -f Sample.pdf
/usr/bin/acroread -toPostScript -size a4 <filename>
/usr/bin/gs -q -sDEVICE=tiffg32d -sPAPERSIZE=a4 -r204x196 -sOutputFile=<outputfile> -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dNOPAUSE -dBATCH -f <inputfile.ps>
and I tested anyways into link for converting, but it doesn't work fine, and most of sending fax have issue.
Also, I have another problem in answer detection beep in my Asterisk when the trunk with Newrock gateway(analog), this is cause some fax doesn't send correctly!
Check hylafax code. It have working script
I use code like this:
gs -sDEVICE=tiffg3 -sPAPERSIZE=$pagesize -r204x196 -dNOPAUSE -dNOPAGEPROMPT -dBATCH -sOutputFile=dest.tif \
-c save pop -f input.pdf -c quit
But actualy it doesn't metter. More important how setup your routes/codecs.
Other problem is for sure offtopic here. You have read more books or hire expert.

How to set the physical size of PDF pages with Ghostscript?

I want to convert a bunch of .eps images to a single PDF using Ghostscript.
But when I look at the PDF file in a PDF viewer and set view to 100% to physical size of the file is huge!
I would like to force gs to create the PDF in letter size, but everything I tried failed.
Here's the command I'm using:
gs -dBATCH -dNOPAUSE -dEPSFitPage -dEPSCrop \
-q -sDEVICE=pdfwrite -sOutputFile=out.pdf \
file1.eps file2.eps
All my attempts with -sPAPERSIZE=legal and -dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h had no effect.
-dEPSFitPage and -dEPSCrop are mutually exclusive. Try getting rid of the -dEPSCrop and putting back -sPAPERSIZE=legal. If that doesn't work, it is probably because the .eps file is over-riding the media, so try adding -dFIXEDMEDIA.
BTW, this answer is cribbed from:
Fit to page size in ghostscript (with a possibly corrupt input)
The problem was -dEPSFitPage it was fitting the page size to the .eps file size... using -dPDFFitPage (and skipping the mutually exclusive -dEPSCrop) solved my problem.
gs -dBATCH -dNOPAUSE -sPAPERSIZE=letter \
-dPDFFitPage -q -sDEVICE=pdfwrite \
-sOutputFile=out.pdf \
file1.eps file2.eps

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

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