Question Marks in XPS Document

隐身守侯 提交于 2019-12-11 14:42:18

问题


I was playing around with XPS in C# and used this example as a starting point: https://code.msdn.microsoft.com/windowsdesktop/How-to-Edit-XPS-file-in-WPF-724ef6fb

I modified the example a bit and created a search and replace application for XPS documents.

The output doesn't look very well:

Copy and paste the question marks to an editor works well and gives me the correct characters.

Now I've found out that when characters are not in the source XPS and new characters are in the target XPS, they can not be found in the font (found this explanation here: https://stackoverflow.com/a/28236296/2058139).

The essence of the problem lies in the use of ODTTF fonts in XPS document. The ODTTF is an obfuscated subsetted font based on the fonts used in the original document. This means that you cannot use for the replacement any character that wasn't in the original document.

Any solution for this?


回答1:


The good news: You've accurately diagnosed your problem.

The bad news: The embedded ODTTF truly does not have the required glyphs for your new text. You will need to embed a new font. It is an awful hack, but it may be possible to determine the original font that was used. If that same font happens to be installed, you can redo the font embedding process, generating a new ODTTF that contains the glyphs you need. Needless to say, this is a terrible hack that can fail badly at several points. How you handle the situation will be highly dependent on the specific use cases for your application.



来源:https://stackoverflow.com/questions/33524172/question-marks-in-xps-document

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!