首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

XPS 打印 字体错误。求各位老大解决

2012-04-02 
XPS 打印 字体异常。求各位老大解决问题1:异常信息:......xxxxx.ttf file does not conform to the expecte

XPS 打印 字体异常。求各位老大解决
问题1:
异常信息:......xxxxx.ttf file does not conform to the expected file format specification.
原因:我在xps中加入了中文。

C# code
//代码片段1 foreach (XpsFont font in fixedPageReader.Fonts)                        {                            string name = Helper.GetFileName(font.Uri);                            string guid = new Guid(GetFileName(font.Uri).Split('.')[0]).ToString("N");                            name = System.IO.Path.Combine(guid, System.IO.Path.GetFileNameWithoutExtension(name) + ".ttf");                            string path = string.Format(@"{0}\{1}", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), name);                            if (!fontList.ContainsKey(font.Uri.OriginalString))                            {                                Helper.SaveToDisk(font, path);                                fontList.Add(font.Uri.OriginalString, path);                            }                        }//代码片段2 foreach (KeyValuePair<string, string> val in fontList)                        {                           page = Helper.ReplaceAttribute(page, "FontUri", val.Key, val.Value);                           //page = Helper.ReplaceAttribute(page, "FontUri", val.Key, "D:\\simsunb.ttf");                        }//代码片段3 FixedPage fp = XamlReader.Load(new MemoryStream(Encoding.Default.GetBytes(page))) as FixedPage;

问题2:自定义一个数据表格绑定完数据后,直接打印 表格出现了,但数据没有,
如果在打印之前加上
PrintDialog dialog = new PrintDialog();

  if (dialog.ShowDialog() == true)
  {
  dialog.PrintVisual(sp, "Print Test");
  }
就能打印出来。求各位老大帮忙解决。

C# code
 private void Print_Click(object sender, RoutedEventArgs e)        {            DataGrid dg = new DataGrid();            dg.ItemsSource = getdata().DefaultView;            StackPanel sp = new StackPanel();            sp.Children.Add(dg);            PrintDialog dialog = new PrintDialog();            if (dialog.ShowDialog() == true)            {                dialog.PrintVisual(sp, "Print Test");            }            VisualPrintDialog printDlg = new VisualPrintDialog(sp);            printDlg.ShowDialog();        }        double width = 11;        double height = 8.5;        private DataTable getdata()        {            DataTable dt = new DataTable();            dt.Columns.Add("aa", typeof(string));            dt.Columns.Add("BB", typeof(string));            dt.Columns.Add("中文", typeof(string));            for (int j = 0; j < 10; j++)            {                string[] objVals = new string[3];                for (int i = 0; i < 3; i++)                {                    string obj = "tets" + j;                    objVals[i] = obj;                }                dt.Rows.Add(objVals);            }            return dt;        }   

在线等。。

[解决办法]
木有做过..
[解决办法]
探讨
问题1:
异常信息:......xxxxx.ttf file does not conform to the expected file format specification.

这个错误是因为字体不识别中文造成的错误。

更换字体试试。

热点排行