I Have a PDF file, I want to convert it to a PS file, then I execute below command
# file d00137-001
/var/spool/cups/d00137-001: PDF document, version 1.4
# gs -dBATCH -dNOPAUSE -q -sDEVICE=ps2write -sOutputFile=d00130 d00137-001
and then, I see a lot of error output:
**** Error: File has an unbalanced >> (close dictionary).
Output may be incorrect.
**** Error: obj definition followed by multiple tokens, attempting to recover.
Output may be incorrect.
**** Error: obj definition followed by multiple tokens, attempting to recover.
...... /* Skip 11 lines of the same output */
**** Error: Tf refers to a resource key with an invalid value type: marktype. Assuming resource key: F7 is a font name.
Output may be incorrect.
**** Error: Tf refers to a resource key with an invalid value type: marktype. Assuming resource key: F7 is a font name.
Output may be incorrect.
...... /* Skip 11 lines of the same output */
# file d00130
/var/spool/cups/d00130: PostScript document text conforming DSC level 3.0, Level 2
# ls -l d00130 d00137-001
-rw-r--r-- 1 root root 203745 3月 15 14:27 d00130
-rw-r----- 1 root lp 6565 3月 15 14:27 d00137-001
But I see d00130 is a blank document when I view it via evince or printing it via a HP printer. Is there a problem with the PDF file format, or do I need to adjust my command parameters? but the original PDF file can be opened for viewing or printing.
Thanks very much.
If you need the original PDF file, you can leave your email and I will send it to you.
Thanks again.
I think this issue is gs did not found the chinese font my used.
That would seem to be highly unlikey. If Ghostscript can't find a font, then it will use a substitute to replace the missing font. Depending on a number of factors it will choose what it think is a 'suitable' font. I won't claim its impossible to defeat this, and get an error instead, but it seems unlikely to me.
this font path is /usr/share/fonts/truetype/yozo/yzdwkj6.ttf, I have try to add this font to /usr/share/ghostscript/9.22/Resource/Init/cidfmap,
OK so that's not a Font, its a CIDFont, there are significant differences.
but the PDF file have below line: /BaseFont /Yozo Kai. how can I do for this description information is a > two-word font?
I assume you mean for a 2 byte encoding. The answer is that you should only have to suuply a CIDFont named "Yozo Kai". However.... Using a space in a font name is a really bad idea, because spaces are delimiters in PostScript and PDF, so the line you've posted above is technically invalid.
Instead of creating a dictionary containing a key /BaseFont
and the value /Yozo Kai
the PDF file actually creates a dictionary with a key /BaseFont
and the value /Yozo
, with a spare string Kai
left lying around. This means the dictionary does not have an even number of entries, and so is illegal. Exactly what happens under these circumstances is not defined.
Note, I'm taking what you say verbatim, since I haven#'t got the PDF file to look at, but this error message:
**** Error: File has an unbalanced >> (close dictionary). Output may be incorrect.
suggests I am correct, the number of entries isn't even so Ghostscript has eaten the closing >>
and then complains because it can't find a closing dictionary mark.
If I use below script to describe this font, printing driver will output filter failed log.
/Yozo Kai << /FileType /TrueType /Path pssystemparams /GenericResourceDir get (/usr/share/fonts/truetype/yozo/yzdwkj6.ttf) concatstrings /CSI [(GB1) 5] >> ;
Same reason, you can't make a name which contains a space like that, because spaces are delimiters. In PostScript (which is how cidfmap is defined) you can do this:
(Yozo Kai) cvn <</FileType...... ...../CSI [(GB1) 5] >> ;
Note that I'm still pretty doubtful about the path you have in there, because that is concatenating the Ghostscript Generic Resource Directory with 'usr/share/...' which seems unlikely to be correct to me. I suspect you simply want /Path (/usr/share/fonts/truetype/yozo/yzdwkj6.ttf)
.
But the real problem is (or appears to be) that your PDF file is broken. The correct way to embed a font with a space in the name would be:
/BaseFont /Yozo#20Kai
That is, you replace the unusable character (in this case space) with an escape character '#' and then follow it with the byte describing the ASCII character you want to use and then carry on. For fonts with multibyte encoding names you have to use escape codes for all the 'unprintable' character codes.
Since your PDF file doesn't follow the rules it is fundamentally broken, you should contact the creators of the software which was used to make the PDF file and inform them that they have a bug. The only way to correct this is going to be to remake the PDF file.