Bug 691861 - PDF does not display
Summary: PDF does not display
Status: RESOLVED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 9.00
Hardware: PC Windows Vista
: P4 normal
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-03 15:48 UTC by Harry McKame
Modified: 2011-01-17 14:25 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
pdf that causes an error (644.24 KB, application/download)
2011-01-03 15:48 UTC, Harry McKame
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Harry McKame 2011-01-03 15:48:58 UTC
Created attachment 7080 [details]
pdf that causes an error

Hi,

The attached pdf causes an error and doesn't display.
Its particularity is that it is created in Arabic and by an unknown tool.

Many thanks,
Harry McKame
Comment 1 Ken Sharp 2011-01-03 16:11:36 UTC
(In reply to comment #0)
> Created an attachment (id=7080) [details]
> pdf that causes an error
> 
> Hi,
> 
> The attached pdf causes an error and doesn't display.
> Its particularity is that it is created in Arabic and by an unknown tool.

Its useful to quote the error, as then we can tell if we are seeing the same error. In this case I see the messages:

Page 1
Scanning c:\gs\fonts for fonts... 95 files, 41 scanned, 35 new fonts.
Substituting font Helvetica-Bold for SimplifiedArabic-Bold.
Loading NimbusSanL-Bold font from c:\gs\fonts/n019004l.pfb... 2730528 1325244 4246672 2944893 3 done.
Can't find CID font "SimplifiedArabic-Bold".
Substituting CID font /Adobe-Identity for /SimplifiedArabic-Bold, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. Will exit with error.
Can't find CID font "SimplifiedArabic-Bold".
Substituting CID font /Adobe-Identity for /SimplifiedArabic-Bold, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. Will exit with error.
Error: /undefined in findresource


This should be quite informative, Ghostscript is telling you that it is unable to find the CIDFont 'SimplifiedArabic-Bold' and is attempting to use a substitute font (it has already substituted Helvetica-Bold for the type 1 version of this font)

GS is unable to find a substitute for the font, and so exits with the error 'undefined in findresource', just as it said it would.

Your PDF file uses several fonts which are not embedded in the file, some of these are CIDFonts. Unlike regular fonts these cannot easily be substituted with other fonts, and when they are not present you will get an error.

As the warning suggests I would direct you to the documentation in gs/doc/Use.htm and the CIDFontSubstitution articel. This will explain what you can do about this problem.
Comment 2 Harry McKame 2011-01-17 10:10:17 UTC
I have been looking some more at the problem, and it seems that every pdf-viewer that I tried can correctly display this file, except GS. Some of them are Foxit Reader, PDF-XChange and of course Adobe Acrobat.

In fact, the font SimplifiedArabic-Bold does exist on every Windows computer, except that GS doesn't use it.

Why doesn't GS, as a simple fail-back measure, try to find a non-CID font of the same name ?
Comment 3 Ken Sharp 2011-01-17 10:28:27 UTC
(In reply to comment #2)

> Why doesn't GS, as a simple fail-back measure, try to find a non-CID font of
> the same name ?

Because is not possible to use a Font as a substitute for a CIDFont, the two are quite different. For starters a CID-keyed instance of a font will use multiple bytes per glyph, whereas a Font will *always* use a single byte per glyph. CIDFonts are generally only used when composed with a CMap in order to create a CID-Keyed instance of a font. You can't combine a Font with a CMap to create a CID-Keyed instance.

See the PostScript Language Reference Manual, section 5.11 "CID-Keyed Fonts" for more information about CIDFonts.

Note that Adobe Acrobat is unable to find a replacement font for 'ArabicTransparent' and instead substitutes Adobe's own CIDFont 'Adobe Sans MM' which doesn't seem likely to me to be correct.
Comment 4 Harry McKame 2011-01-17 11:01:27 UTC
Well, whatever Adobe reader and the other viewers are doing, it works, even if not 100% correct.

There an infinite distance between (1) rejecting a pdf and (2) doing a half-way decent job of displaying it.

You may have set the status of this question to Resolved, but I stay unconvinced.
Comment 5 Ken Sharp 2011-01-17 11:15:06 UTC
(In reply to comment #4)
> Well, whatever Adobe reader and the other viewers are doing, it works, even if
> not 100% correct.
> 
> There an infinite distance between (1) rejecting a pdf and (2) doing a half-way
> decent job of displaying it.

That's true, one of the differences is that you will know immediately that the output is not correct, as opposed to finding out when someone else points it out. A number of PostScript users set up RIPs so that they throw errors on missing fonts, not just CIDFonts, rather than replace them and get half-way correct output.

The PDF file doesn't contain the font, Ghostscript hasn't been told where to find a replacement, it also hasn't been supplied with a general purpose CIDFont replacement (which is something of a problem anyway). So an error is the only remaining option.

 
> You may have set the status of this question to Resolved, but I stay
> unconvinced.

If you load the TrueType font as a CIDFont, using the instructions I mentioned in Comment #1 then you should be able to render the file properly:

"As the warning suggests I would direct you to the documentation in
gs/doc/Use.htm and the CIDFontSubstitution article. This will explain what you
can do about this problem."

The behaviour is as defined, and so this is not a bug, I've given you the information on how to load the font into Ghostscript, hence the 'resolved' status. If you find that the font can't be loaded into GS, or gives an incorrect result, then that would possibly be a bug, but it would be a different problem.
Comment 6 Harry McKame 2011-01-17 11:58:44 UTC
Ken, yes, I understood that I can tell GS my TrueType equivalence for the CID font SimplifiedArabic-Bold. But that means that I will need to redo it for every CID font in my pdf file. In fact, several CID fonts were declared in the attached file, but none were included.

And I will need to repeat the action for the next pdf with CID fonts? And how do I communicate my equivalents to other people ?

I do not see why you cannot add a "font correctness" parameter to GS, that could have (for example) 3 settings:
1. Severe : all fonts required to be present,
2. Medium : CID fonts required to be present,
3. Lenient : allow replacement of CID fonts by non-CID of same or similar name.

In the Lenient setting, GS will make every effort to display the pdf and use any font with same or similar name. If the user just wants to see what is in the pdf, why reject him out-of-hand?
Comment 7 Ken Sharp 2011-01-17 12:06:25 UTC
(In reply to comment #6)

> And I will need to repeat the action for the next pdf with CID fonts? And how
> do I communicate my equivalents to other people ?

You need to install fonts to Ghostscript, the installer will do this but only for fonts present when you install, and it can't install TrueType fonts as CIDFonts because it doesn't know how to (extra information is required about how the font will be used).

 
> I do not see why you cannot add a "font correctness" parameter to GS, that
> could have (for example) 3 settings:
> 1. Severe : all fonts required to be present,
> 2. Medium : CID fonts required to be present,

You can already do this (though not like that).


> 3. Lenient : allow replacement of CID fonts by non-CID of same or similar name.

Because you can't substitute a Font for a CIDFont, it just isn't possible they are different animals.


> any font with same or similar name. If the user just wants to see what is in
> the pdf, why reject him out-of-hand?

Because we can't do it, simple as that really.
Comment 8 Harry McKame 2011-01-17 12:57:27 UTC
Ken, I am just a user of pdf software and beyond considering the "should" and "should-not" of pure pdf interpretation. All I can see is that all other pdf viewers do automatically and as a matter of course what you say cannot be done. And furthermore that you define "cannot be done" as "can be done if the equivalence is specified in a text file".

It is not clear for a user that when the Fonts Manager shows "Simplified Arabic Bold", then this satisfies the requirement for "SimplifiedArabic-Bold". Yet you require that of anybody that happens upon such a pdf. And then you further require that one finds out which GS file to update, to learn postscript syntax (yucks), and to update the file correctly.

Can't you see that you are not being very user-friendly? That your product lacks an algorithm that all the other viewers have implemented?
Comment 9 Ken Sharp 2011-01-17 13:26:00 UTC
(In reply to comment #8)
> Ken, I am just a user of pdf software and beyond considering the "should" and
> "should-not" of pure pdf interpretation. All I can see is that all other pdf
> viewers do automatically and as a matter of course what you say cannot be done.
> And furthermore that you define "cannot be done" as "can be done if the
> equivalence is specified in a text file".

Not exactly. I'm saying that you cannot replace a CIDFont with a Font. That is definitely the case. There is no 'equivalence' here, you can load a TrueType font in such a way as to mimic a Font, or to mimic a CIDFont. If you load it as a Font, you can't then decide to use it as a CIDFont.

As you've pointed out, the 'text' file is in fact a PostScript program. If you run the font through one program you get a PostScript Font, if you run it through a different program you get a CIDFont.

Other applications can, like Ghostscript, use a TT font on disk as if it were a CIDFont. GS can do this if you 'install' the font correctly (ie add it to cidfmap). Clearly other applications are doing something like this. That is, they are using the existing TrueType font as a CIDFont, they aren't using a Font as a CIDFont.

Essentially they are doing automagically what I'm saying you need to do with GS.

(NB When I say 'Font' I mean a PostScript or PDF font object, I do not mean a TrueType font file, a PostScript Font is quite different from a PostScript CIDFont)
 

> Can't you see that you are not being very user-friendly? That your product
> lacks an algorithm that all the other viewers have implemented?

Yes, its not user-friendly, PostScript never was, and at heart Ghostscript is still a PostScript engine.

This also leads to part of the problem. Ghostscript (unlike Adobe Acrobat) processes both PostScript *and* PDF. Anything we do needs to be compatible with both. There are certain assumptions you can make if you only intend to handle PDF which you cannot make if you also expect to handle PostScript. 

I would also point out that there are things you can do, or support, if you only intend to run on a limited number of platofrms, like Adobe, which we can't do because we support a whole range of operating systems, and we just don't have the resources to devote to all of them. And our commercial customers, who understand these issues, have their own solutions to font installation, and our commercial customers have first call on our resources. 

The Ghostscript application isn't really a 'product' as such, its a useful example of how to interface with Ghostscript, and it has sufficient functionality that many people have found it to be useful as-is.

The only way to address your problem is to add the fonts to Ghostscript as CIDFonts. Currently this is not done at installation time, I don't deal with the installers  but its possible that someone could come up with a way to install the fonts as CIDFonts when GS is installed (it already does install the TT fonts as fonts). The information probably wouldn't be correct, but it might be sufficient to work, sometimes. This would not help you if you install fonts after installing Ghostscript of course.

Anyway, that would be a separate enhancement request, please feel free to open such a request (the component would be config/Install in this case)
Comment 10 Harry McKame 2011-01-17 13:49:30 UTC
Not wishing to keep on badgering you, my last (really last) remark is that the other products are apparently doing on-the-fly conversion of fonts to CIDFonts, as well as locating these fonts in the first place.

I understand commercial realities, and so consider that I have done all that I could. My only request is for you not to forget the above remark.
Comment 11 Ken Sharp 2011-01-17 14:02:22 UTC
(In reply to comment #10)
> Not wishing to keep on badgering you, my last (really last) remark is that the
> other products are apparently doing on-the-fly conversion of fonts to CIDFonts,

I think you mean conversion of TrueType fonts to CIDFonts, you really, really can't convert PostScript Fonts into CIDFonts. Well, technically I suppose you could, in as much as almost anything is possible in software, but I don't think it would work well/properly.


> as well as locating these fonts in the first place.

As I said, that's down to the installer, or operating-system-specific hooks. The Windows font system is really quite different to the Linux system. The Ghostscript font system is independent of the OS for exactly this reason.
 

> I understand commercial realities, and so consider that I have done all that I
> could. My only request is for you not to forget the above remark.

As I said, I'd suggest that you open an enhancement request for the installer, its the only realistic place to define TrueType fonts stored on the system into CIDFont analogues.
Comment 12 Harry McKame 2011-01-17 14:10:33 UTC
I mean rather the conversion of locally installed fonts to CIDFonts, TrueType or not (if at all possible).

I really think that this should be on-the-fly and not in the installer. So where should I open this as an enhancement request ?
Comment 13 Ken Sharp 2011-01-17 14:25:30 UTC
(In reply to comment #12)

> I mean rather the conversion of locally installed fonts to CIDFonts, TrueType
> or not (if at all possible).

Its only possible with TrueType fonts (or OpenType fonts, same thing really), PostScript fonts are already of the correct type. Since we're planning to deprecate XFont support that doesn't really leave any other types.

 
> I really think that this should be on-the-fly and not in the installer. So
> where should I open this as an enhancement request ?

It can't (won't if you prefer) be done on the fly, because that would require the font searching mechanism (which lives in the PostScript world) to be operating-system specific, so that it could search the OS font folder(s) or call OS-specific API calls to find any/all fonts on the system.

If you want to you can open an enhancement request against Ghostscript to do that, but I suspect it will be declined pretty quickly.

You could ask for a stand-alone tool to do this for Windows, someone might feel inclined to write something like that, especially since the existing installer does a lot of the work.

For any of these, including enhancements to the installer, you can open a request here in Bugzilla, just set the 'Severity' to 'enhancement'.