TTF in PostScript using Ghostscript not showing glyphs in Adobe lIlustrator - ghostscript

So, I have a PostScript that I'm converting into PDF using a custom font i.e. one that isn't included in the computer/Ghostscript library originally.
The font is rendered correctly in the PDF (visbly and its embedded stated by the pre-flight prespress analysis), and when the PDF is viewed in Photoshop it looks good also.
However, the issue is when I bring it into Illustrator the font glyphs are not recognised and appear as a .notdef character (a rectangle with a cross through it).
Within Illustrator I have the font installed when I view it in my dropdown of fonts. But this still doesn't help.
Has anyone else had this issue or can even replicate it?
I have used two (following) processed to include fonts into my ghostscript environment to troubleshoot but both produce incorrect results.
Converted the TTF into Type42
Added TTF into Ghostscript FontMap
Attached is the ZIP file containing the PDF and the TTF font I've used (I have used others also with the same results). If you need anymore files please let me know and I'll update.
Zip file
Below is the PostScript file (very simple) and my execution.
%!ps-nonconforming
/inch {72 mul} bind def
/Pacifico 20 selectfont
1 inch 10 inch moveto
/fontheight currentfont dup /FontBBox get dup 3 get % top
exch 1 get sub % top - bottom
exch /FontMatrix get 3 get mul def % adjusted by height multiplier
/lineheight fontheight 1 mul def % add 20% for line spacing
/newline {0 lineheight neg rmoveto} bind def % negate height to move downwards
gsave (lineheight: ) show lineheight 20 string cvs show grestore
newline gsave (Museo) show grestore
Command:
gs -o fonttest.pdf -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 \
-dPDFSETTINGS=/prepress fonttest.ps
P.S.: I know that this could be an Illustrator bug, to which I have opened up a support ticket, but this can also be the way I'm embedding the font or someone out there may just have the answer :D

I found this thread UTF-8 PDF generated with TCPDF showing up fine in Adobe Acrobat but corrupted in Illustrator and Google preview which spoke about corruption in Illustrator.
Using this I thought that it was likely subsetting causing the issue in ghostscript.
Found this thread How to make GhostScript PS2PDF stop subsetting fonts and applied the Ghostscript options to stop font subsetting.
So in my command to Ghostscript I use the
-dSubsetFonts=false
and that worked! In Illustrator the font displays as expected.
So my full gs command is:
gs -o output.pdf -sDEVICE=pdfwrite -dCompatibilityLevel=1.3 \
-dSubsetFonts=false -dPDFSETTINGS=/prepress input.ps

Related

PDF generated with ghostscript (no output fonts) has defects (missing outlines)

Following of question: Convert PDF to get vectorized text ("convert all text to outlines")
The PDF generated with the gs -o outputPath.pdf -dNoOutputFonts -sDEVICE=pdfwrite inputPath.pdf has a defect. Around some font characters, some outlines have disappeared when I inspect it deeply with Inkscape (View / Display Mode / Outlines). See:
Link of the file for further inspection: https://filetransfer.io/data-package/nwsra9yl#link
How to solve this? Is there an option in the ghostscript command that I could add to solve this? Thanks.

Ghostscript - EPS (with embedded TIFF with transparent background) to PNG conversion

I'm trying to convert an EPS file with an embedded TIFF that has a transparent background to a PNG using GhostScript. The problem that I am having is that the background of the TIFF image becomes white in the PNG. It looks like the following:
IncorrectPNG
When I export from Adobe Illustrator, it comes out correct:
CorrectPNG
I was reading that there is not transparency in EPS, only marked and unmarked areas. I was wondering if there was a call that I was missing that would create the PNG through Ghostscript similar to that of Illustrator? Or if there is any other alternative that doesn't just replace white with transparency through ImageMagick?
I am using Windows and have Ghostscript 9.25 installed. Here is the command (one of many) that I've tried:
-q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -sDEVICE=pngalpha -r300 -dEPSCrop NamePlatePNG.png NamePlate.eps
I can get the EPS file to you if needed. Any help would be appreciated, thanks!
UPDATE:
Here is the EPS file (Hopefully this link works):
https://drive.google.com/open?id=1m4HHGLoPe0jdWkx1Oghe7ttiXPldZnJs
Also, I should have mentioned that the images I uploaded were just screenshots of the PNGs open in an image editor. The checkered portion is indeed fully transparent alpha channel. I was trying to easily accentuate the difference.
Your file doesn't look like its transparent, it looks like its masked, possibly with a stencil mask, possibly chroma-keyed. Without seeing the file I can't tell for sure.
You are correct that PostScript (and hence EPS) doesn't support transparency, but it does support several features which have somewhat similar effects.
The color space is irrelevant, and in fact the only kind of 'transparency' supported in PostScript works when the color space is CMYK, but not when its RGB (and certainly not sRGB, which isn't even a PostScript color space, you have to manufacture it from CIEBasedABC)
As far as I can see the command line you are using is correct, but as I say I can't tell much without seeing the actual EPS program.
[EDIT]
So the Ghostscript rendering is correct, that's what is in your EPS file, there is no transparency of any kind there. So how is Illustrator able to make a transparent PNG ? Well the answer is that Illustrator isn't using the PostScript part of the EPS file.
About 1/3 of the way through the EPS file you'll see a line which reads:
%AI9_PrivateDataBegin
What follows that is an Adobe Illustrator file format. When AI reads the file it finds that line, throws away the PostScript portion of the file, and reads the AI representation of the content from the portion of the file beginning with that comment.
Now stored somewhere in there will be the information that portions of the content are transparent. Although PostScript can't represent that, Illustrator's internal format can. So when you write a PNG file from Illustrator it knows that portion is transparent and writes it as such.
Ghostscript, however, is constrained by the PostScript portion of the file, it can't read the Illustrator native format, and so renders the image with a white background.
It 'might' be possible to save a different kind of EPS from Illustrator (level 3 instead of level 2 possibly, I notice this is a language level 2 EPS file) which duplicate the effect, but from what you have here, there isn't anything a standard PostScript interpreter can do which will give you the result you want.

Ghostscript cuts off part of image

I have this eps image named "input.eps".
I run the following command on it:
gs -dNOPAUSE -dBATCH -q -sDEVICE=ps2write -sOutputFile=output.eps input.eps
The resulting output file "output.eps" has the right side of the figure chopped off. Why?
Note: The reason I'm using GhostScript is to change the fonts in the input.eps file, which I'll do by specifying the -I switch with the path to the fonts. I haven't put that in the code snippet as it is not relevant to the issue.
EPS files do not request a media size (they are intended for inclusion in a PostScript program by applications). So, if you don't tell Ghostscript what size media to use it has no choice but to use its default.
Depending on your operating system (and locale if appropriate), this is likely to be either Letter (612 by 792 units) or A4 (596 by 842 units). Your EPS file claims it has a Bounding Box of 1008 units by 504 units.
So clearly your EPS won't fit across the media, and will therefore be cropped.
You can either wrap the EPS up as is normal for inclusion in a PostScript program, and request the media there, or you can use the -dEPSCrop switch which reads the Bounding Box from the comments and uses that for a media request.
Note that, despite the existence of the BoundingBox, this is not technically a valid EPS file. It has the wrong DSC identifier and executes showpage.
As a final note, you won't be 'changing' the fonts in the EPS file, as the EPS file does not contain any fonts, just references to font names.

GhostScript PDF to PostScript

I have to convert pdf files (created with jasperreports) to postscript.
I'm using ghostscript (Version 9.19) to make the conversion.
The commmand i'm using is:
gswin64c -dNOPAUSE -dBATCH -sDEVICE=ps2write -sOutputFile=file.ps file.pdf
The conversion is done without problem, but when i open the postscript file generated (using GSview 5.0), the top margin is crop by 2-3 cm, and some information to print is lost.
I have changed the device from ps2write to eps2write, used the property -g<width>x<height> with the page size in pixels, but the problem persist.
The file is to be printed in a preformated paper, so i can not use the postscript generated to print.
Can someone help?
Thanks
Its not possible to say with great certainty, but it sounds like the PDF mediaBox is larger than the media you have specified to GSView.
You can try using the -dDEVICEWIDTHPOINTS and -dDEVICEHEIGHTPOINTS along with -dFIXEDMEDIA and -dPDFFitPage, that should allow you to set up a specific media size, override the size in the PDF file and scale the result to fit the specified size.
Perhaps you could post an example PDF file, without that its very hard to comment sensibly.

can I use Ghostscript to overlay a text (fax) header onto a PDF and/or TIFF?

I'm writing an application that faxes a document (many supported types) provided by the end user. A requirement is that the end user can also provide text to be used as part of a custom fax header.
I've been using Ghostscript to render PDFs as TIFFs and it's been working great so far, but I have yet to find a straightforward way of overlaying the custom header at the top of a PDF. I've tried out a few recommendations:
How can I make a program overlay text on a postscript file?
How can I add a footer to the bottom of each page of a postscript or pdf file in linux?
Add comments to PDF files automagically with regular expressions
Stamp PDF file with control for position of stamp file
... with no luck.
I've used ImageMagick to do this successfully with documents rendered to TIFF via other tools, and I'm aware that ImageMagick can render PDF-to-TIFF on its own. However, I want to stick with Ghostscript because in my experience it has performed better and rendered clearer TIFFs.
Is this possible using Ghostscript and perhaps a PS helper script?
Edit:
Ghostscript (v9.04) is not throwing any errors. For example:
gswin64c -dSAFER -dBATCH -dNOPAUSE -dPDFFitPage -sDEVICE=tiffg3 ^
-sOutputFile=goofy.tif ^
-c "/Courier findfont 12 scalefont setfont 50 765 moveto (header text) show" ^
-f goofy.pdf
... produces a TIFF of the original PDF, but without the text I tried to add. If I append showpage to the postscript one-liner it (predictably, I suppose) prints a new, blank-except-for-header page, which doesn't help me much.
I would use another commandline tool combined with Ghostscript for this task. This tool is pdftk.exe. Then use a 3 step approach:
The task of Ghostscript would be to create an (otherwise empty) page with the header text:
gswin64c.exe ^
-o header.pdf ^
-sDEVICE=pdfwrite ^
-c "/Courier findfont 12 scalefont setfont" ^
-c "50 765 moveto (header text) show showpage"
The task of pdftk would be to overlay (stamp or background) the PDF file with the text header over the original PDF:
pdftk.exe goofy.pdf background header.pdf output goofy-with-header.pdf or
pdftk.exe goofy.pdf stamp header.pdf output goofy-with-header.pdf
The last step is to employ Ghostscript again in order to create your final TIFF output:
gswin64c.exe ^
-dPDFFitPage ^
-o goofy-with-header.tif ^
-sDEVICE=tiffg3 ^
goofy-with-header.pdf
I just tried your exact same approach with your exact same result. Then I removed -dSAFER from my command-line arguments and it works like a charm.
The way I see doping it is appending what you need on the PDF to the PDF file itself - before any conversion - the PDF filew format is designed so that one can append extra information at the end of the file (even information that goes on previous pages).
Unfortunatelly, I never worked on it - so I can'tell you eactly what you need to do - maybe there is aome PDF editing library in a programing language that would make this task easier - else you will have to create the PDF bits yourself. (Tradiditional libraries that render PDF's from some input format won't do, as you have to work inside the structure of your existing document) - but maybe taking a looka t the PDF specification can enlighten you on this approacj, and you check if it is worth:
http://www.adobe.com/devnet/pdf/pdf_reference_archive.html
Another approach there would be to work on the "other end" of your files: layout text on the post-rendered TIFF files using an image manipulation library. This is only possible, of course, if there is a fixed space on the pages reserved for you to add the information.
Sorry for not being able to offer a complete solution

Resources