ghostscript convert pdf to pcl with wrong orientation - windows

I have an issue trying to convert a pdf document to a pcl document using Ghostscript.
The original pdf document is landscape and so the pcl should be as well. Nevertheless in windows using Ghostscript 9.14 with the following command functions:
gswin32 -dNOPAUSE -dBATCH -sDEVICE=ljet4 -dSAFER -dAutoRotatePages=/NONE -sPAPERSIZE=a4 -sOutputFile=./convert_windows.pcl ./duplicate_windows.pdf
The same command in Ubuntu Linux Kernel Version 3.2.0-40-generic 64 bit - but with Ghostscript 9.05 - results in a wrong orienteated pcl file of size A3 instead of A4 as the original.
The original pdf file contains windows font "arial", which should be available in linux as well. The package "msttorcefonts" is installed on linux. This is an short extract of the fontmap of Ghostscript:
cat /usr/share/ghostscript/9.05/Resource/Init/Fontmap.GS
gives:
% This font, and only this font among the Hershey fonts, uses
% the SymbolEncoding.
/Hershey-Symbol (hrsyr.gsf) ; % 5066567
/Arial /ArialMT ;
/Arial,Bold /Arial-BoldMT ;
/Arial,Italic /Arial-ItalicMT ;
/Arial,BoldItalic /Arial-BoldItalicMT ;
The following listing shows the output of the linux command line, which is the same output as from the windows Ghostscript console!
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Loading NimbusMonL-Bold font from /usr/share/fonts/type1/gsfonts/n022004l.pfb... 3627296 2211468 1767360 473754 3 done.
Loading NimbusSanL-Bold font from /usr/share/fonts/type1/gsfonts/n019004l.pfb... 3668288 2319461 1807728 497748 3 done.
Loading NimbusSanL-Regu font from /usr/share/fonts/type1/gsfonts/n019003l.pfb... 3800176 2466391 1827912 512832 3 done.
Loading NimbusMonL-Regu font from /usr/share/fonts/type1/gsfonts/n022003l.pfb... 3964224 2617715 1969200 654805 3 done.
Page 2
I alredy tried several options of Ghostscript like
-dFIXEDMEDIA
-dNORAGEPAGESIZE
and others.
When converting the pdf document to ps the result is the same on both environments.
Does anyone has experiences with that issue or an idea?
Thanks in advance and kind regards

Its unlikely anyone can help at all without seeing teh original PDF file, so I would suggest that you open a bug report and attach the PDF file there.
A few observations:
-dAutoRotatePages only has an effect when creating a PDF file, not when interpreting one.
The switch -dFIXMEDIA should be -dFIXEDMEDIA, likewise NORAGEPAGESIZE should be NORANGEPAGESIZE

This may be a possible solution, which works in my case. Precondition: Ghostscript Version 8.6.0 or higher!
Converting pdf to ps not with gs command, but with gs wrapper pdf2ps, which is part of the ghostscript package:
pdf2ps input.pdf output.ps
BUT: For landscape pdf documents this works only since version 8.60 or higher! Otherwise landscape documents will be printed in portrait.
Converting pdf to pcl worked for me using the following command:
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ljet4 -sPAPERSIZE=a4 -sOutputFile=output.pcl -c "<< /InputAttributes << currentpagedevice /InputAttributes get { pop null } forall >> dup 0 << /PageSize [ 595 842 ] >> put >> setpagedevice" save pop -f input.pdf
BUT: This command is based on the documentation of Bug Bug 689919 of ghostscript (refer to http://bugs.ghostscript.com/show_bug.cgi?id=689919) and works for portrait-orientated documents only if you have installed a version 8.60 or higher. Because I have three different environments I can approve, that this command works since version 8.60. I used Versions 8.16, 8.62 and 9.05.
For versions 8.62 and 9.05 of ghostscript both commands worked properly for pdf --> ps and pdf --> pcl for landscape and portrait.

Related

cannot edit ghostprint ppd in Windows 10

I had some difficulty posing my problem in a way that the Title filter found pleasing. The real problem is that modifying only the GhostPDF.PDD file in the GS9.26 installation in Windows 10 doesn't seem to affect the output after a re-installation using Windows 10 Device Installer.
I print to a networked Sun SPARCprinter 1 which is controlled by Ghostprint (script?) compiled to run on SunOS 4.1.4. This has worked successfully for some years printing output from Windows XP using Adobe's PS driver and a SPARCstation PPD cobbled together from samples found on the net.
I've installed Artifex's 9.26 on Windows 10 and output to an LPR printer (The Sun). The output works, is recognized as PS output by the Sun, but produces a number of FATAL errors.
I need to edit the Windows Ghostscript installation to output PS files which are more suitable for the Sun.
So to my simple question: Do I need to modify anything in the Ghostscript Windows 10 installation other than the Ghostpdf.PPD file?
additional info:
SPARCstation 10 information:
SunOS 4.1.4
arcad# gcc -dumpversion
2.95.2 Note: I had to bootstrap this version up from the early GCC which could be compiled with the SunOS 4.1.4 C compiler. I had the impression I couldn't bring it up any further but could be mistaken.
arcad# gs --help
Aladdin Ghostscript 6.01 (2000-03-17)
Copyright (C) 2000 Aladdin Enterprises ...
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
-dNOPAUSE no pause after page | -q `quiet', fewer messages
-g<width>x<height> page size in pixels | -r<res> pixels/inch resolution
-sDEVICE=<devname> select device | -dBATCH exit after last file
-sOutputFile=<file> select output file: - for stdout, |command for pipe,
embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PDF
.....
For more information, see /usr/local/share/ghostscript/6.01/doc/Use.htm.
Note: I think this is the most recent GS version I can compile with this gcc version
printcap section:
gp|GhostPrinter:\
:lp=/dev/lpvi0:sd=/var/spool/gsprintspool:lf=/var/spool/gsprintspool/log:\
:mx#0:sh:if=/usr/local/libexec/lpfilter-gps:
Typical spool file - "....." indicates stuff not included here"
arcad# more dfA004DESKTOP-M8C5I86
%!PS-Adobe-3.0
%%Title: Document
%%Creator: PScript5.dll Version 5.2.2
%%CreationDate: 12/14/2018 19:56:8
%%For: jferg
%%BoundingBox: (atend)
%%Pages: (atend)
%%Orientation: Portrait
%%PageOrder: Special
%%DocumentNeededResources: (atend)
%%DocumentSuppliedResources: (atend)
%%DocumentData: Clean7Bit
%%TargetDevice: (Ghostscript) (3010) 815
%%LanguageLevel: 3
%%EndComments
%%BeginDefaults
%%PageBoundingBox: 0 0 612 792
%%ViewingOrientation: 1 0 0 1
%%EndDefaults
.....
%%EndResource
userdict /Pscript_WinNT_Incr 230 dict dup begin put
%%BeginResource: file Pscript_FatalError 5.0 0
userdict begin/FatalErrorIf{{initgraphics findfont 1 index 0 eq{exch pop}{dup
length dict begin{1 index/FID ne{def}{pop pop}ifelse}forall/Encoding
{ISOLatin1Encoding}stopped{StandardEncoding}if def currentdict end
/ErrFont-Latin1 exch definefont}ifelse exch scalefont setfont counttomark 3 div
cvi{moveto show}repeat showpage quit}{cleartomark}ifelse}bind def end
%%EndResource
userdict begin/PrtVMMsg{vmstatus exch sub exch pop gt{[
quires more memory than is available in this printer.)100 500
more of the following, and then print again:)100 485
put format, choose Optimize For Portability.)115 470
ce Settings page, make sure the Available PostScript Memory is accur--More--(2%)
ce the number of fonts in the document.)115 440
ocument in parts.)115 425 12/Times-Roman showpage
Error: Low Printer VM ]%%)= true FatalErrorIf}if}bind def end
2016 ge{/VM?{pop}bind def}{/VM? userdict/PrtVMMsg get def}ifelse
.....
SPARCprinter PDD file which works with Adobe PS in Windows XP:
john#hp2:~/sun-stuff/cups-sparc$ more SPARCprinter2.ppd
*PPD-Adobe: "4.1"
*% PostScript(R) Printer Description File for SPARCprinter
*% Date: 94/01/14
*% Copyright 1994 Sun Microsystems, Inc. All Rights Reserved.
*% Permission is granted for redistribution of this file as
*% long as this copyright notice is intact and the contents
*% of the file is not altered in any way from its original form.
*% End of Copyright statement
*% Changed margins on SPARCprinter JAF 3-3-2017
*FormatVersion: "4.1"
*FileVersion: "1.10"
*LanguageEncoding: ISOLatin1
*LanguageVersion: English
*PCFileName: "SPRN.PPD"
*Product: "(SPARCprinter)"
*PSVersion: "(3.000) 0"
*ModelName: "SPARCprinter"
*ShortNickName: "SPARCprinter"
*NickName: "SPARCprinter"
*% ==== Device Capabilities ===============
*LanguageLevel: "3"
*Extensions: CMYK Composite
*FreeVM: "4194304"
*ColorDevice: False
*DefaultColorSpace: Gray
*VariablePaperSize: False
*TTRasterizer: None
*FileSystem: False
..... more of the usual stuff
I don't really understand why you have installed Ghostscript on Windows. Windows is perfectly capable of producing PostScript files all of its own. In addition, the PPD file doesn't actually do very much, it is simply a text file with descriptions of the capabilities of the printer.
So the real problem is, or seems to be, that your SUN setup doesn't like the PostScript being produced by the new version of Windows.
You don't say how you are printing the PostScript file. not how your printer is 'controlled by Ghostscript' (I'm not aware of any product called Ghostprint, there is a GSPrint as part of GSView, but that's really for Windows).
Assuming you are using Ghostscript on your Sparc workstation to drive the pritner, then the most likely problem I would say is that you are using an old version of Ghostscript on the workstation, and it doesn't like the PostScript being generated by the newer version of Windows.
If you had included the transcript from the workstation Ghostscript installation it might be possible to say more but without that I'm rather guessing.
Another possibility is that you are using the ps2write device in Ghostscript to produce PostScript files on Windows. I can't think why you would be doing that, but it sort of fits your description. In that case editing the PPD file will have no effect, because Ghostscript doesn't use it.
Now the ps2write device emits level 2 PostScript, the clue is in the name, and its possible again that your Sparc setup is so elderly that it doesn't understand level 2, or doesn't fully implement it. In which case you will probably get errors. Again, if you were to provide the text of the error messages this would help!
In the latter case, you are frankly out of luck. We dropped support for level 1 PostScript output some time ago, what with level 2 being 28 years old now and level 3 coming up on 20. If you need language level 1 output you will have to go back to a very old version of Ghostscript. Something like 9.07 (from 5 and a half years ago) was the last version that included the pswrite device.
With effort you could take the pswrite device and upgrade it so that it works with the current version of Ghostscript
[EDIT]
My word, that's a really old version of Ghostscript!
You could try building a new version to replace it, but I also don't know if current code will compile on gcc 2.95. It 'should' because we only expect C89, but the third party libraries (which are essential) may very well not compile.
The PostScript file you quoted has been produced by Windows, not by Ghostscript (%%Creator: PScript5.dll Version 5.2.2). So it seems likely to me that your problem is the PostScript being produced by the newer version of Windows doesn't work with your 18 year old version of Ghostscript. That's not actually entirely surprising.
If you look at the DSC comments it says:
%%LanguageLevel: 3
And your Ghostscript information says that it supports language levels 1 and 2. At the time the level 3 spec had only just been published (1999), and clearly the maintainers back then hadn't had time to fully implement it.
Note that the ghostpdf.ppd file is intended for use with Ghostscript as a 'print to PDF' printer along with the RedMon port monitor.
Now its not obvious to me which PPD file you are using, but..... Both the ghostpdf.ppd file and the sparcprinter ppd file have :
*LanguageLevel: "3"
That tells the PostScript driver that it can use language level 3, which your Sparc Ghostscript doesn't support. You could try changing that to:
*LanguageLevel: "2"
and see if that makes a difference (you will have to uninstall the printers from Windows and re-install them with the modified PPD file).
If it doesn't work, the only other thing I can think of is to use the Ghostscript you installed on the Windows system, and preprocess the PostScript file produced by Windows before you send it on. You can use the ps2write device in Ghostscript 9.26 to take in the level 3 file, and produce a level 2 file. It might be a bit bigger, but it ought to work.
To do that on Windows you would use something like:
gswin64c -sDEVICE=ps2write -sOutputFile=out.ps <input.ps>
The file 'out.ps' should then be a level 2 PostScript file. I can't guarantee that the output will then work the old version of Ghostscript on your Sparc, but you stand a chance!

imagemagick won't recognize new path to Ghostscript

I'm trying to convert some PDFs to jpegs using imagemagick . I'm working on win 10, 64 with python 3.62 - 64 bit and wand 0.4.4. I've been able to get wand working with ImageMagick-6.9.9-Q16-HDRI. I have all this set up on a E USB flash drive. I've set both the Path and MAGICK_HOME env vars to
E:\ImageMagick-6.9.9-Q16-HDR;E:\gs\bin
Originally I installed ghostscript 9.22 - 64 at E:/gs9.22 , but the I read ( PythonMagick can't find my pdf files) that 64 bit may not work so I deleted that and got ghostscript 9.22 - 32 bit, which I installed as above.
I ran:
$ convert myfile.pdf test.jpg
convert.exe: FailedToExecuteCommand `"E:/gs9.22/bin/gswin64c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=png
alpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" "-sOutputFile=C:/Users/MYaCCount/AppData/Local/Temp/magick-9524p6yKrXNmpJc3%d" "-fC:/Users/MYaCCount/AppData/Local/Te
mp/magick-9524TRGHmKoW5SkX" "-fC:/Users/MYaCCount/AppData/Local/Temp/magick-9524pKGelk0Un3Bp"' (The system cannot find the file specified.
) # error/delegate.c/ExternalDelegateCommand/459.
convert.exe: PDFDelegateFailed `The system cannot find the file specified.
' # error/pdf.c/ReadPDFImage/809.
convert.exe: no images defined `test.jpg' # error/convert.c/ConvertImageCommand/3258.
Why is the system looking for the 64 bit ghostscript path (which I deleted) ? I have closed and reopened my editor and the environmental var editor.
I ended up using the regedit utility to manually go through and remove all traces of 'ImageMagick'. The included uninstall utility in Imagemagick did not remove everything. After this I was able to install new versions.

PDF to PNG conversion using Ghostscript: only the fist page is in the output PNG file

I am using Ghostscript on Windows 7 machine to convert PDF to PNG. My input PDF has many pages but the PNG file only contain the first page !
I am using the following command line:
gswin64c -sDEVICE=png16m -r720x720 -dNOPAUSE -dBATCH -sOutputFile=79245340005_1602.png 79245340005_1602.pdf
and the logfile is as follow:
GPL Ghostscript 9.20 (2016-09-26)
Copyright (C) 2016 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Page 2
As you can see, it seems that both pages are processed but only the first one appear in the final PNG file. Any idea what is wrong in my command line ? I try to look a the documentation but didn't find what I am doing wrong. If I have a single PDF file with 10 pages, I wand a single output PNG file with 10 pages.
My original command line was as follow but had the same issue:
gswin64c -q -sPAPERSIZE=a4 -sDEVICE=png16m -dTextAlphaBits=4 -r720x720 -o 79245340005_1602.png -dNOPAUSE -dBATCH 79245340005_1602.pdf
Thanks
Fabien
PNG can hold only one image per file. Use TIFF or the like for multiple images per file.
Try to use following syntax to achieve rasterizing into several png's
gswin64c -q -sPAPERSIZE=a4 -sDEVICE=png16m -dTextAlphaBits=4 -r720x720 -o -sOutputFile='79245340005_1602_%00d.png' -dNOPAUSE -dBATCH 79245340005_1602.pdf

How to get page size(Trim/Bleed/Art/Media....) in PDF with GhostScript 9.19 in windows 10?

I want page size (Trim/Bleed/Art/Media....) in PDF with GS 9.19 in windows 10.
I tried this command :
gswin64c -dNODISPLAY -q -dDumpMediaSizes "../lib/PDFA_def.ps" test.pdf
, but I had below error.
Error: /undefinedfilename in --file--
Thank you for your information.
Why would you think that pdfa_def.ps, which is used to create a PDF/A compliant PDF file would give you any information ?
I suspect you actually mean pdf_info.ps, which is located in the toolbin folder, not the lib folder.

How to make croatian characters show correctly on all platforms in a PDF?

I've created this small Postscript to create a test page:
100 100 moveto
/Courier findfont 10 scalefont setfont
(This is croatian characters test: ) show
/scaron glyphshow
/dcroat glyphshow
/ccaron glyphshow
/cacute glyphshow
/zcaron glyphshow
/Scaron glyphshow
/Dcroat glyphshow
/Ccaron glyphshow
/Cacute glyphshow
/Zcaron glyphshow
showpage
I ran it through ps2pdf shell on Linux (on Fedora 13 and Enterprise release 5), and the resulting PDF shows up good on these systems. However, if I try to open the document on a Windows system (tested on Windows XP, Vista and 7), the characters /dcroat, /ccaron, /cacute, /Dcroat, /Ccaron and /Cacute don't show up at all! Can someone please point me in the right direction about where the problem might be and perhaps the solution?
I've run this through multiple versions of GS, the latest being GPL Ghostscript 8.71 (2010-02-10). The result is always the same. The resulting PDF can be found here (scroll down on the page to see text).
Use gs (Ghostscript) instead of ps2pdf to convert your PostScript file to PDF. (ps2pdf is only a simple wrapper around a Ghostscript commandline anyway.)
As you are using Courier (which is one of the 'base 14' fonts), Ghostscript will by default NOT embed the font into the PDF. That means, you'll have to use some additional commandline magic to enforce the Courier embedding:
gs \
-o croatian-glyphs.pdf \
-sDEVICE=pdfwrite \
-c ".setpdfwrite <</NeverEmbed [ ] /AlwaysEmbed [/Courier]>> setdistillerparams" \
-f croation-glyphs.ps
Note, that when I run this command on my Mac, I see only 4 croatian characters in the output (scaron, Scaron, zcaron and Zcaron). The reason for this is: my Courier here does not have all of the croatian glyphs which were asked for (and hence cannot embed them).
However, if you run this command on a system which has a Courier including the other glyphs, and if you pass me your resulting PDF, I could see the glyphs just fine (since the font, or at least the subset of glyphs in use, is now embedded in the PDF).
Try to embed fonts by using ps2pdf -dEmbedAllFonts=true ...

Resources