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
Related
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.
How can I read the files contained in the directory d:\ with batchscript not one by one files like that. I have tried the following:
#echo off
"C:\Program Files\gs\gs9.25\bin\gswin32c.exe" -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 -dPDFSETTINGS=/printer -dColorImageResolution=90 -dAutoRotatePages=/None -dBATCH -dNOPAUSE -sOutputFile=d:\d\koran.pdf *d:\a\01.pdf d:\a\02.pdf d:\a\03.pdf d:\a\04.pdf d:\a\05.pdf d:\a\06.pdf d:\a\07.pdf d:\a\08.pdf d:\a\09.pdf d:\a\10.pdf d:\a\11.pdf d:\a\12.pdf d:\a\13.pdf d:\a\14.pdf d:\a\15.pdf d:\a\16.pdf d:\a\17.pdf d:\a\18.pdf d:\a\19.pdf d:\a\20.pdf d:\a\21.pdf d:\a\22.pdf d:\a\23.pdf d:\a\24.pdf*
exit
Ghostscript doesn't 'merge' PDF files. It creates new PDF files by interpreting the contents of its input, this is not the same thing. You should read the documentation here
You haven't said what the problem is with the command you have tried, its going to be hard to help you if you don't do that.
The most likely problem is that you have put * characters at the start and end of the input filenames. Ghostscript itself doesn't match wildcards, it expects you to tell it each file you want to process individually. So in order to process a directory of files is to first get a list of all the files, and then tell Ghostscritp to use each of those files in turn.
You can use the Ghostscript #filename syntax (documented here)to tell Ghostscript to use the contents of a file as if it were the command line.
So all you need to do is come up with a shell script which will write the filenames from a folder into a file. That's not a Ghostscript question, and depends totally on the operating system you are using.
For Windows something like:
dir /B *.pdf >> files.txt
gswin32c -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile=\temp\out.pdf #files.txt
del files.txt
might be sufficient for your needs.
I could not make it work using "files.txt" but I am using this and everything works just fine.
gswin64c -sDEVICE=pdfwrite -dBATCH -dNOPAUSE -sOutputFile="out.pdf" (Get-ChildItem -Path .\*.pdf)
You can execute like below:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf *.pdf
Reference:
https://gist.github.com/moaazsidat/b94185e9cfdba9e3cfb5bc90407e6397
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
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
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