Ghostscript PDF fonts becomes boxes in Adobe Illustrator where as its output is fine when opened in Adobe Acrobat - ghostscript

I need to convert the PDF of RGB color space to Grayscale using commandline tool supporting for Windows and Linux.
When i used Ghostscript the conversion is happening but when the output is opened in illustrator the fonts were shown as boxes.
Is there any solution option available in Ghostscript to overcome this font issue.
Is there any other commandline tool available for this conversion.
The font encoding is always built in is there any ways available to change it as ANSI encoding.Screenshot of font issue on illustrator VS the working scenario on acrobat

Pictures of the problem really don't help. You need to provide the following:
The version of Ghostscript you are using, and the platform (Linux, Windows etc), the word size of the version of Ghostscript and where you sourced this version of Ghostscript from (official Ghostscript download page, package, self-built binary).
An example file to reproduce the problem
The exact command line you used to reproduce the problem, and any supporting files required.
I suspect that your problem is that the original PDF file does not include the fonts that it uses, and that you have left SubsetFonts as true, and have left the AlwaysEmbed and NeverEmbed arrays untouched. This will mean that the new PDF file also does not include the fonts, which means that any PDF consumer must use a substitute font. The 'boxes' you refer to are /.notdef glyphs which are used when the font does not contain the glyph being requested.
Having the Encoding 'built-in' doesn't help with anything at all, it's the presence or absence of the fonts which matters. No, you can't change the encoding to 'ANSI', if you do that (assuming it isn't already WinAnsiEncoding) you'll see very similar problems to the ones you are complaining of here. You would also need to change the text character codes in the PDF file to be able to change the Encoding.
You could also raise this as a bug at https://bugs.ghostscript.com, where you will also have to supply an example file (as simple as possible) and all the other information listed above.

Related

Ghostscript - Can't find (or can't open) font file

I try to create a image from a pdf in php (imagemagic). On the image text is missing.
To debug this problem i went to the CLI and use the folowing command:
gs -sDevice=png16m -sOutputFile="test.png" test.pdf
Now I get:
GPL Ghostscript 9.26 (2018-11-20)
Copyright (C) 2018 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Querying operating system for font files...
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/ArialMT.
Can't find (or can't open) font file ArialMT.
Loading ArialMT font from /usr/share/fonts/truetype/msttcorefonts/Arial.ttf... 4395876 2792289 6087360 4693359 4 done.
Can't find (or can't open) font file /usr/share/ghostscript/9.26/Resource/Font/Arial-BoldMT.
Can't find (or can't open) font file Arial-BoldMT.
Loading Arial-BoldMT font from /usr/share/fonts/truetype/msttcorefonts/arialbd.ttf... 4395876 2792684 6897144 5444610 4 done.
Can't find CID font "Arial".
Attempting to substitute CID font /Adobe-Identity for /Arial, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. attempting to use fallback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font Adobe-Identity ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
Warning: falling back to Identity ordering
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font CIDFallBack ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
**** Error: can't process embedded font stream,
attempting to load the font using its name.
Output may be incorrect.
Can't find CID font "Arial".
Attempting to substitute CID font /Adobe-Identity for /Arial, see doc/Use.htm#CIDFontSubstitution.
The substitute CID font "Adobe-Identity" is not provided either. attempting to use fallback CIDFont.See doc/Use.htm#CIDFontSubstitution.
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font Adobe-Identity ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
Warning: falling back to Identity ordering
Loading a TT font from /usr/share/ghostscript/9.26/Resource/CIDFSubst/DroidSansFallback.ttf to emulate a CID font CIDFallBack ... Done.
Can't find CMap Identity-UTF16-H building a CIDDecoding resource.
**** Error reading a content stream. The page may be incomplete.
Output may be incorrect.
**** Error: File did not complete the page properly and may be damaged.
Output may be incorrect.
%%BoundingBox: 85 470 562 757
%%HiResBoundingBox: 85.491068 470.681986 561.761983 756.827977
I found a lot of topics and tried a lot but I can't fix the problem. I think the problem is the CID font but I'm not sure.
Can someone give me some tips how I can solve this problem?
Server: Debian GNU/Linux 9 (stretch)
Ghostscript: GPL Ghostscript 9.26 (2018-11-20)
You appear to have several problems. It's hard to say for certain because you haven't supplied the PDF file to inspect.
Firstly your PDF file appears to be trying to use a CIDFont called 'Arial' which it does not embed in the PDF file. It also doesn't contain the regular fonts ArialMT and Arial-BoldMT but you appear to have substitute fonts available either from fontmap.GS or via fontconfig (if your build includes that) for those.
Failing to embed fonts is poor practice, failing to embed CIDFonts is specifically frowned upon in the PDF specification.
Ghostscript tries its fallback approaches to define a substitute CIDFont for the missing Arial CIDFont. Firstly it tries the fallback font Adobe-Identity (the name is derived from the CIDSystemInfo) but that CIDFont is also not available. So it drops back to the next attempt, which is to use DroidSansFallback.
However that fails because, in order to produce a satisfactory substitute, Ghostscript needs a CMap, in order to build a CIDDecoding resource. It seems that your installation is missing the relevant CMap.
It looks like your distribution has packaged Ghostscript so that it does not use a ROM file system. Instead it 'looks like' all the files are installed on disk under /usr/share/ghostscript/9.26
You should look for the directory /usr/share/ghostscript/9.26/Resource/CMap and see if there is a file there called Identity-UTF16-H.
I'm going to guess there isn't, and this will be due to a decision made by your package maintainer. I have no idea why they would choose not to include that file but without it (and the other files in that folder) the CIDFont support will be hampered.
If it's not present I'd suggest you take it up with the Debian package maintainer. As Ghostscript is licensed under the AGPL the source code (including all the support files) is of course available from the Ghostscript Git repository and the Ghostscript web site. You could pick up the missing file(s) from there.
Note that the current version is 9.27 and I would recommend upgrading.

Why are my TrueType hints ignored?

I have integrated some hints (a prep handler to update the cvt and glyph instructions (simple MIAPs to copy the cvt values to specific points) into a custom TTF font.
I changed the fonts via Python fontTools.ttx
The font and the hints work perfectly when I test the font in TrueTypeViewerQt.
The font (and the hints) work also in PIL.
I can also see the hints in FontForge (for prep and the glyphs), but debugging them just shows "".
I also get this message in the console window:
SplineFontPieceMeal() going unhinted...
When I now use the font from a PDF file (written via reportlab), the font is used, but my hints seem to be ignored by Acrobat Reader, Ghostscript, mudraw, Chrome Web Browser (integrated PDF view), or an own application based on PDFium.
Then font exported from the PDF (via mutool) still contains the hints which work in TrueTypeViewerQt.
PDF: https://www.dropbox.com/s/qn3iooazsq1z2w5/d85.pdf?dl=0
Font: https://www.dropbox.com/s/p6qwug9h6vcgps0/testbar.ttf?dl=0
Any ideas?

Cannot extract the embedded font - Code Igniter and dompdf

Following the instruction in this link ( https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf ), I always encounter an error when opening the pdf file created. The error message is:"Cannot extract embedded font 'TradeGothicLT-CondEighteen'.Some characters may not display or print correctly. " and when i click OK, the pdf displays black background and when i start highlighting the body, it captures the text but text are in black font-color. what should I do to get rid of this error?
There may be something wrong with your font cache, located at dompdf/lib/fonts/dompdf_font_family_cache.php (though the exact file name depends on your release and whether you have loaded fonts). This file tells dompdf what fonts are available for use in the PDF. If this file references a font that isn't actually available you can run into major issues on viewing. You may need to re-load your font files. Take a look at the Unicode how-to for an overview of using embedded fonts. This document hasn't been updated to reflect changes implemented in dompdf 0.6.0 beta 3, but the information is still pertinent.

How do you reliably render Khmer (Indic) fonts on the web (and in PDFs)?

I've been having a world of trouble getting Khmer fonts (an Indic script of Cambodia) to render reliably on the web across platforms (Mac, Windows, Linux).
Google web fonts recently added Khmer, which seems like the best bet. However, I have not been successful getting Khmer fonts to work on any Mac or Linux system. I can get them to work on Windows by installing the Khmer Unicode installer from http://khmeros.info but not by just including Google's font in an HTML file.
For example, see this screenshot of the Google web fonts page on a fresh Windows installation. You can see that the default Windows Khmer font (uuuuugly!) is being used instead of Danh's pretty fonts.
I have another test file here: http://dl.dropbox.com/u/634/khmer_test.html. For the first test, you should see something like this for both the web font and the default system font (assuming you have Hanuman installed). I have yet to find a system where both examples work reliably.
Any help would be greatly appreciated. My primary goal is to get this working on a website; a secondary goal is to get Khmer (and other Indic fonts) working in a PDF generator like iText (although I am aware iText itself does not support Indic fonts -- I'm hoping something similar does).
Every Cambodian Windows users are always delete the font name called: KhmerMool and Khmer Kampot. Then they change the default Khmer font in regedit too. You can check at http://thelifeandwork.blogspot.com/2010/01/changing-default-khmer-font-in-windows.html . I'm not sure about Khmer font and other Indic font in PDF. I always have problem when i copy Khmer unicode from PDF to put in OpenOffice or Office Word or LibreOffice.
Khmer Unicode displays on the web, it will always solve now by Google Webfont, please refer to that.
And if you want to have Khmer display in PDF by converting using iText, you can see following post:
Khmer Unicode in iText
http://ask.osify.com/qa/287
They are currently not yet support the display yet.
But, just today I can get it works by modifying the source code of iText (5.5.4-SNAPSHOT) as I just stated in my post: http://ask.osify.com/qa/613, not yet be able to publish since it's just start in testing around.
Updated 13/01/2016
I have added the source code sample for the rendering: http://ask.osify.com/qa/613
The rendering customization with iText for Khmer Unicode added in github: https://github.com/Seuksa/iTextKhmer

Miktex on Windows Vista

I have some problems with Miktex installed on Windows Vista Business SP1/32 bit. I use miktex 2.7, ghostscript, and texniccenter 1 beta 7.50. When I compile a document with the following profiles: Latex=>DVI, Latex=>PDF everything works fine; the system crashes when I compile with profiles Latex=>PS and Latex=>PS=>PDF. The error is reported into a window that states: "Dvi-to-Postscript converter has stopped working". What can I do? I need Latex=>PS=>PDF to include my images into the final PDF.
Thanks in advance,
Yet another LaTeX user
If everything you need is images, you could still compile directly to PDF. You only need to have an image in PNG or JPG format, and use the following code:
%in the document preamble
\usepackage{graphicx}
%in the document, in the place where you want to put your image
\includegraphics{image_filename_without_extension}
When the image is a PNG or JPG file (there are some more, I don't remember which ones ATM), you can compile the file with pdfLaTeX, but not with the normal LaTeX (i.e. you can produce a PDF, but not DVI or PS).
Of course normally, if everything works fine, it's nice to have one copy of the image in EPS, and another in, say, PNG -- this way you can compile easily both to PDF, and to PS.
Hope that helps.
Thanks for reply. I have solved the problem: the dvi crashed because I have installed Miktex with the User Account Control enabled. I have disabled it, reinstalled and now it's working (with UAC still disabled).

Resources