0
votes

When I use command gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dNOOUTERSAVE -dSAFER -dPDFSETTINGS=/prepress -dCompressFonts=true -dSubsetFonts=false -dEmbedAllFonts=true -sColorConversionStrategy=RGB -dCompatibilityLevel=1.6 -sOutputFile=output.pdf new27.pdf to convert my pdf file, then I get new file.

I find an error in this new pdf file when I open it in Adobe Acrobat Reader: new pdf screenshot

this is original pdf's fonts: original

this is new pdf's fonts after converted: new

Whether there is a parameter controlling ghostscript does not change the embedded font?

1
Sending pictures of the font list isn't going to help, you need to make the PDF file available. Ideally along with a transcript of the Ghostscritp back-channel so that we can see if Ghostscript tried to tel you anything (eg your font is broken).KenS
@KenS pdf can be opened using adobe acrobat,not word online, I find qpdf+ghostscript can repair it. but gs shows pdf lost some fonts,so I embed no-embedded font using itext, when I use ghostscript to convert pdf ,a custom font is missingtiny
I don't disbelieve you. But there's nothing anyone can do without seeing the file. When faced with a problem everyone seems to look for a magic Ghostscript parameter which will solve their problem, there is no such parameter, I'm not sure why people persist in thinking there is. Either there's a problem in your original file, or you've found a bug. I can't even tell which without seeing the PDF file. Pictures don't help. Oh you also haven't given the version of Ghostscript you are using or the operating system. My first suggestion would be to drop PDFSETTINGS.KenS
@KenS this is my pdf file link . “Ghostscript may do font substitution, so the font embedded may differ from that specified in the original file. ”,I think that's the problem. ghostscript changed the custom fonts, then a custom font was missingtiny
No, font substitution only takes place if the font is not embedded in the PDF file (or the font embedded in the PDF file is corrupted/broken/invalid). Ghostscript does not summarily substitute fonts. And in this case it hasn't substituted the font, according to your images, it hasn't embedded the fotn at all. I'll get the file and look.KenS

1 Answers

0
votes

Well, the problem is that the type 1 font data is not being embedded, and because these are subset names (and using custom encodings as a result) there is no way for a PDF consumer to create a working substitute font.

The FontDescriptors are present, but the actual font data is not. I have no idea why, I've never seen a problem like this before, you should report a bug to https://bugs.ghostscript.com.

It would probably help if you could find (or create) a much simpler example, the original file has 4 pages and uses 18 type 1 fonts, none of which appear to be embedded in the output. A single short line of text using one font would be ideal if you can create that.

[update]

One of my colleagues looked at the file for me. The problem is in the PDF file, specifically the fonts. Each font contains a /.notdef glyph (which is required) and each one begins with an undefined op code (0x00). This means the font is genuinely broken.

So why doesn't this cause a problem for Acrobat (or, indeed, Ghostscript when rendering) ?

Because ordinarily the /.notdef glyph isn't used, its only used when you try to draw a glyph which isn't present in the font (and is therefore a required entry in the font, its the only glyph which must be present).

But when creating a PDF file the Ghostscript PDF device converts the type 1 font to a more compact form, the Type1C or CFF font. That means parsing the glyph descriptions, and one of the descriptions that it must use is the /.notdef, because that's required in all fonts.

When Ghostscript tries to parse the /.notdef glyph it fails, so it abandons embedding the font. It still emits the FontDescriptor in an attempt to produce a working file; if the font was not subset a usable replacement might be found. In this case, because the font is subset and uses a Custom Encoding that isn't possible.

There are other aspects of the font which are less than ideal, for instance the Font BoundingBox is defined as /FontBBox [0 0 0 0] which is clearly nonsense. The font name is, basically, garbage and what appears like an attempt at a subset prefix is incorrect, it should be XXXXXX+, ie 6 characters then a '+', not 3.

By the way, the pictures in your original post have font names which don't match (not evn a little bit) the names of the fonts in the PDF file you attached. That means I can't be absolutely sure that its the same problem, but I would suspect it is.

If you open the file in Adobe Acrobat, export to PostScript, and then attempt to create a PDF file from that PostScript using Adobe Acrobat Distiller it throws an error:

%%[ Error: invalidfont; OffendingCommand: definefont; ErrorInfo: .notdef --nostringval-- ]%%

So an Adobe application also throws an error when processing the font.

I don't know where you sourced the font(s) you are using, but you should replace them with better ones, these are broken.