Link to home
Start Free TrialLog in
Avatar of MikeCausi
MikeCausi

asked on

Converting postscript to pdf (font problem)

I am using ghoscript to convert a postscript file to pdf in windows.  Here is my command line:

gswin32c.exe -sFONTPATH=c:\windows\fonts -sDEVICE=pdfwrite -sOutputFile=C:\Data\FileUpload\tax.pdf C:\Data\FileUpload\tax.ps

The problem that I'm finding is that ghostscript always wants to substitute the Helvetica font in the .ps file to ArialMT.

I've installed the Helvetica font on my machine, so I know it is there, but I cannot figure out how to prevent ghostscript from substituting the font.

I read something about a fontmap file but cannot see/figure it out exactly.
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Fontmap.GS has substitutions for most Windows fonts to 'free fonts' which are found in C:\Program Files\gs\fonts .

http://ghostscript.com/FAQ.html
Avatar of MikeCausi
MikeCausi

ASKER

I've looked at that fontmap.gs file (I've attached it here -- I've renamed it to .txt for uploading).

I'm not sure exactly what to change in that file to force the helvetica to use the helvetica font in my windows font folder.

This is my script call:

gswin32c.exe -I"c:/temp/fontmap.gs" -sFONTPATH=c:/windows/fonts -sDEVICE=pdfwrite -sOutputFile=C:\Data\FileUpload\testconfirm.pdf C:\Data\FileUpload\testconfirm.ps


What would I need to modify in there for it to stop subbing the helvetica?

Thanks.
fontmap.gs.txt
I don't have time to go thru it.  But I would suggest that (after you make a backup copy), you just remove any lines that have Helvetica in the left column so that it doesn't have a sub specified.  That may not be all of it though since Windows itself has font substitution tables somewhere, probably in the Registry.
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Joe, while that does get me the Helvetica onto the PDF, it seems to be having problems with French accent characters using the Helvetica fonts.

During the processing Ghostscript it is giving me the error

"Warning: glyf overlaps cmap, truncating".

The output pdf scrambles all french accented characters.

In my fontmap file, I added the helvetica .ttf file as you indicated above and it does use Helvetica properly (for the most part)

When I view the PDF, the propertes/fonts show the encoding of the Helvetica font as "Built in" instead of Ansi (when I use distiller which produces good files).

Is there something to do with the encoding that I have to change?
Mike,
I don't know why that's happening. I ran the same [gswin32c.exe] command here and it worked fine on a PS file containing French characters with accents. I attached the PDF file resulting from my execution of the [gswin32c.exe] command for you. I don't have Helvetica on my system, so I used Arial...that could certainly be the difference, but I just don't know. A Google search for "warning glyf overlaps cmap truncating" turns up plenty of hits, as does "ghostscript french characters", but I'd just be shooting in the dark to recommend anything...which you can easily do yourself (some of the Google hits do talk about encoding...with references to The Red Book). Sorry I couldn't help further. Let's hope some other EE experts jump in. Regards, Joe
gswin32c-ps-to-pdf-conversion-fr.pdf
Joe, when I let GS run against Arial font it works fine as well (as you found out).   Not sure why the Helvetica font (when it actually gets to show Helvetica font via fontmap file) doesn't handle for special accents.

I'm still researching the glyf warning (assuming it's related).
Mike,
Thanks for the update...this is a curious one! Regards, Joe
Thought I'd add this comment.

The problems I'm having are with customer files.

If create my own sample postscript file with the following in it:

%!
/Helvetica findfont 72 scalefont setfont
72 72 moveto
(Helvética R!) show
showpage

It used the fontmap file correctly, gave me the correct Helvetic font, and even converted the French accent properly.


However, I notice that the customer files (which I cannot post here due to privacy concerns) uses a different method to create french characters.

They have something more along the lines of:

(helv)(\302)(etica)

in their files

They've done something different which I do not understand to put the special accent onto the e.

Not sure if this means anything to anyone?
I can explain the "\302" (I'm sure you know that "helv" is Helvetica font and "etica" is Etica font...it's likely that Etica was chosen as a free font very similar to the non-free Helvetica).

ASCII characters were originally 0-127 (decimal). Then came along extended ASCII, with codes 128-255 (decimal). Many of the extended ASCII codes are for accented characters, such as in the list I attached earlier. Now, in postscript, the backslash is an escape character, and numerous codes can follow it...if it's three numbers, that means it's an ASCII character in octal. So, 302 octal is 194 decimal (and C2 hex), and is the capital letter A with a circumflex (Â). Regards, Joe
Hi Mike,
It's been a week since our last exchange on this...any updates to report? Thanks, Joe
The font that the postscript file is actually using Helvetica.   The sample code I gave you just happened to break the text on "Helv" and "Etica".   Its not actually using the Etica font.

I was simply trying to test ghoscript against two methods of french characters.   One method where the accent was literally in the text, and another where it uses ASCII chars to represent accents, and ghostscript isn't converting the ASCII ones well.

Unfortunately, the .ps files I'm receiving are all ASCII ones.

(So, I'm still stuck at this point since I don't have control over the .ps files)
Mike,
Here's another idea. IrfanView is excellent freeware imaging software that I've been using for many years:
http://www.irfanview.com/

Click the Download link on the left to download IrfanView and click the PlugIns link on the left to download the PlugIns, which are needed to give you PDF capability (it's optional...only if you want PDF support...and the other features that come with the PlugIns). Install IrfanView first, then install the PlugIns (again, it's optional, but I think it's a good idea).

IrfanView supports PS files, so open your PS file in it (drag-and-drop or File>Open). Although I recommended that you install the PlugIns to get PDF support, that was just for future, general usage. In this case, do NOT use IrfanView to save as PDF, because IrfanView uses Ghostscript, so you're likely to run into the same problem. Instead, print it to doPDF, an excellent (and also free!) PDF print driver. Download is here:
http://www.dopdf.com

The thing about doPDF is that it does not use Ghostscript. Let me know what happens. Regards, Joe
I will take a look and get back to you.  Thanks.
Mike,
Sounds good. Looking forward to hearing if that works for you. I tested it here on a sample AI file that I downloaded from the web and it worked fine, but, as always, YMMV. Regards, Joe
I ended up going with Acrobat Distiller for these particular post script files.  However, I give points out for the effort plus I learned some stuff about the font maps etc.
Mike,
Thanks for posting the solution that worked for you...and for awarding the points...both very much appreciated! Regards, Joe