Solved

Converting postscript to pdf (font problem)

Posted on 2013-06-17
17
1,061 Views
Last Modified: 2013-08-03
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.
0
Comment
Question by:MikeCausi
  • 8
  • 7
  • 2
17 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
0
 

Author Comment

by:MikeCausi
Comment Utility
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
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
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.
0
 
LVL 51

Accepted Solution

by:
Joe Winograd, EE MVE earned 500 total points
Comment Utility
You may add your own fonts to the [fontmap.gs] file. Edit the file in any text editor, such as Notepad, and add your Helvetica entries at the bottom (it is recommended to put them at the bottom since later entries in the file override previous ones...so a font you add at the bottom will override a font earlier in the file...not an issue in this case, but good practice).

I don't know how Linotype/Monotype GmbH distributes its Helvetica font, but let's say you have Helvetica Bold Oblique in a file called [helvbo.pfa]. Put this at the end of the [fontmap.gs] file:

/Helvetica-BoldOblique (helvbo.pfa)

Add other fonts similarly, such as:

/Helvetica-TextbookRoman (helvtr.pfa)

Regards, Joe
0
 

Author Comment

by:MikeCausi
Comment Utility
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?
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
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
0
 

Author Comment

by:MikeCausi
Comment Utility
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).
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Mike,
Thanks for the update...this is a curious one! Regards, Joe
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:MikeCausi
Comment Utility
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?
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
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
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Hi Mike,
It's been a week since our last exchange on this...any updates to report? Thanks, Joe
0
 

Author Comment

by:MikeCausi
Comment Utility
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)
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
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
0
 

Author Comment

by:MikeCausi
Comment Utility
I will take a look and get back to you.  Thanks.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
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
0
 

Author Closing Comment

by:MikeCausi
Comment Utility
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.
0
 
LVL 51

Expert Comment

by:Joe Winograd, EE MVE
Comment Utility
Mike,
Thanks for posting the solution that worked for you...and for awarding the points...both very much appreciated! Regards, Joe
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

If your app took Google’s lash recently, here are the 5 most likely reasons.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now