In short, I am dealing with a problematic PDF, which:
- Cannot be fully displayed in a document viewer, such as
evince , due to lack of font information; - However -
ghostscript can fully display the same PDF file.
This way - regardless of what ghostscript uses to fill in the gaps (maybe reverse glyphs or some other font access method) - I would like to be able to use ghostscript to create ("distill") the output PDF, where practically nothing will be changed, except for the added evince information, so evince can display the same document in the same way as ghostscript .
My question is - is it even possible; and if so, what will be the command line to achieve something like this?
Thanks a lot in advance for any answers,
Hurrah!
Details:
Actually, I am on earlier Ubuntu 10.04, and I may experience - not an error, but a problem with installing evince (lack of poppler-data package), as indicated in Error # 386008 "Some fonts do not appear due to" Unknown font tag ... ": Errors: package" poppler ": Ubuntu .
However, this is exactly what I would like to process, so I will use fontspec.pdf attached to this post (" PDF that launches the error. ", / / v.) to demonstrate a problem.
evince
First, I open this pdf page in evince ; and evince complains:
$ evince --page-label=3 fontspec.pdf Error: Missing language pack for 'Adobe-Japan1' mapping Error: Unknown font tag 'F5.1' Error (7597): No font in show Error: Unknown font tag 'F5.1' Error (7630): No font in show Error: Unknown font tag 'F5.1' Error (7660): No font in show Error: Unknown font tag 'F5.1' ...
The result is as follows:

... and it’s obvious that some forms of fonts are missing.
Adobe acroread
Just notice how Adobe Acrobat Reader for Linux behaves; following command line:
$ ./Adobe/Reader9/bin/acroread /a "page=3" fontspec.pdf
... does not generate output to the terminal (for more on /a switch, see Man page acroread ) - and the program has absolutely no problems with displaying fonts.
<sub> In addition, although I would like to avoid going back to the postscript, however, note that acroread itself can be used to convert PDF to postscript:
$ ./Adobe/Reader9/bin/acroread -v 9.5.1 $ ./Adobe/Reader9/bin/acroread -toPostScript \ -rotateAndCenter -choosePaperByPDFPageSize \ -start 3 -end 3 \ -level3 -transQuality 5 \ -optimizeForSpeed -saveVM \ fontspec.pdf ./
Again, the above command line will not generate output to the terminal; -optimizeForSpeed -saveVM is, because, apparently, they deal with fonts; the final argument ./ is the output directory (the output file is automatically called fontspec.ps ).
Now evince can display previously missing fonts in the output of fontspec.ps , but complains again:
$ evince fontspec.ps GPL Ghostscript 9.02: Error: Font Renderer Plugin ( FreeType ) return code = -1 GPL Ghostscript 9.02: Error: Font Renderer Plugin ( FreeType ) return code = -1 ...
... and besides, all the text seems to be smoothed out with curves in the postscript, so now you can no longer select the text in the .ps file in evince (note that the .ps file cannot be opened in acroread ). However, you can convert this .ps back to .pdf again:
$ pstopdf fontspec.ps
... and now the text in pstopdf output can be selected in evince , all fonts are there, and evince no longer complains. However, as I already noted, I would like to avoid accessing postscript files altogether. Sub>
display (from imagemagick )
We can also monitor the page in the same document using imagemagick display (note that panning an image from the command line using 'display' is apparently not yet available, so I used -crop below to configure the viewport):
$ display -density 150 -crop 740x450+280+200 fontspec.pdf[2] **** Warning: considering '0000000000 00000 n' as a free entry. ... **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.5.4 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe published PDF **** specification.
... which generates some ghostscrip ish errors - and leads to something like this:

... where it is obvious that the missing fonts that evince cannot display are now shown here, with the imagemagick display , correctly.
ghostscript
Finally, we can use ghostscript as an x11 viewer - observe the same page, the same document:
$ gs -sDevice=x11 -g740x450 -r150x150 -dFirstPage=3 \ -c '<</PageOffset [-120 520]>> setpagedevice' \ -f fontspec.pdf GPL Ghostscript 9.02 (2011-03-30) Copyright (C) 2010 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. Processing pages 3 through 74. Page 3 >>showpage, press <return> to continue<< ^C
... and the result with this output:

In conclusion: ghostscript (and , apparently by extension, imagemagick ) can apparently find the missing font (or at least some replacement for it), and display a page with this - even if evince fails at the same time for the same document.
So I just would like to export the PDF version from ghostscript , which will contain only missing fonts and other processing; so i try this:
$ gs -dBATCH -dNOPAUSE -dSAFER \ -dEmbedAllFonts -dSubsetFonts=true -dMaxSubsetPct=99 \ -dAutoFilterMonoImages=false \ -dAutoFilterGrayImages=false \ -dAutoFilterColorImages=false \ -dDownsampleColorImages=false \ -dDownsampleGrayImages=false \ -dDownsampleMonoImages=false \ -sDEVICE=pdfwrite \ -dFirstPage=3 -dLastPage=3 \ -sOutputFile=mypg3out.pdf -f fontspec.pdf GPL Ghostscript 9.02 (2011-03-30) Copyright (C) 2010 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. **** Warning: considering '0000000000 00000 n' as a free entry. Processing pages 3 through 3. Page 3 **** This file had errors that were repaired or ignored. **** The file was produced by: **** >>>> Mac OS X 10.5.4 Quartz PDFContext <<<< **** Please notify the author of the software that produced this **** file that it does not conform to Adobe published PDF **** specification.
... but it does not work - the output file mypg3out.pdf suffers from the same problems in evince , as noted earlier.
Note. Although I would like to avoid the postscript browser, a good example of the gs command line from pdf to ps with font insertion is: (# 277826) pdf - How to make GhostScript PS2PDF terminate a subset of fonts ; but the same command line switches to .pdf to .pdf so as not to affect the problem described above.