XPS 打印 字体异常。求各位老大解决
问题1:
异常信息:......xxxxx.ttf file does not conform to the expected file format specification.
原因:我在xps中加入了中文。
问题2:自定义一个数据表格绑定完数据后,直接打印 表格出现了,但数据没有,
如果在打印之前加上
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
dialog.PrintVisual(sp, "Print Test");
}
就能打印出来。求各位老大帮忙解决。
在线等。。
异常信息:......xxxxx.ttf file does not conform to the expected file format specification.
原因:我在xps中加入了中文。
//代码片段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");
}
就能打印出来。求各位老大帮忙解决。
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;
}
在线等。。
...全文
相关推荐
PrintXPS:命令行XPS打印
PrintXPS是一个命令行工具,用于打印XPS文件。它通过初始化COM库和多线程模式来执行打印任务,并遵循GNU通用公共许可证。程序首先检查命令行参数,然后创建XPS对象模型工厂,启动打印作业,并处
xps2pdf.zip
总的来说,"xps2pdf.zip"提供的工具是一个实用的解决方案,帮助用户解决XPS与PDF格式之间的兼容性问题,尤其对于那些需要在各种设备和操作系统上分享文档的用户来说非常有价值。
打印机驱动卸载工具
总的来说,这款“打印机驱动卸载工具”通过其核心执行文件XPSRemovalTool.exe,配合xps.xml的配置指导,为用户提供了一种高效、专业的解决方案,帮助他们轻松卸载打印机驱动,尤其是与XPS
C#实现xps转图片
**错误处理和资源释放**:在整个过程中,确保捕获可能出现的异常,并在操作完成后正确关闭和释放所有使用的资源,避免内存泄漏。
XPS_PageManipulatorTool【xml编辑】【vb.net】
XPS(XML Paper Specification)是微软提出的一种开放标准,用于创建、呈现和打印固定布局的文档。它类似于PDF,但更专注于Windows环境。


