在文档查看器中显示 XPS 文档
我正在尝试使用文档查看器和 XPS atm,因为我之前从未尝试过。 因此,我有一段简单的代码来加载 XPS 文档并将其显示在文档查看器中,但是该文档没有出现。 文档查看器加载并在调试模式下快速执行一步告诉我信息在那里,只是不会显示。
dvDoc = new DocumentViewer();
string fileName = null;
string appPath = System.IO.Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentWindow)).CodeBase);
if (type == "About")
fileName = appPath + @"\Documents\About.xps";
fileName = fileName.Remove(0, 6);
XpsDocument doc = new XpsDocument(fileName, FileAccess.Read);
dvDoc.Document = doc.GetFixedDocumentSequence();
我能找到的所有文献都告诉我这样做,但它似乎对我不起作用。 我知道文档查看器不喜欢 URI,因此需要 filename.remove 行。
关于我所缺少的任何建议。
干杯, 苏姆盖伊
I'm having a go with document viewer and XPS atm as I haven't tried it before. So I have a simple piece of code loading an XPS document and displaying it in the document viewer, however the document doesn't appear. The document viewer loads and a quick step through in debug mode tells me the information is there,it just won't show.
dvDoc = new DocumentViewer();
string fileName = null;
string appPath = System.IO.Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentWindow)).CodeBase);
if (type == "About")
fileName = appPath + @"\Documents\About.xps";
fileName = fileName.Remove(0, 6);
XpsDocument doc = new XpsDocument(fileName, FileAccess.Read);
dvDoc.Document = doc.GetFixedDocumentSequence();
All literature I can find tells me to do it this way yet it doesn't seem to work for me. I'm aware that document viewer doesn't like URI's, hence the filename.remove line.
Any suggestions as to what I'm missing.
Cheers,
SumGuy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
差不多一个月过去了,你可能已经明白了这一点。
您的文档查看器似乎不是 xaml 文件的一部分。 看起来您正在创建一个新的 DocumentViewer 对象,但从未将其添加到 xaml 文件中。
而不是
在您的 xaml 文件中声明它:
You've probably already figured this out by now since it's been almost a month.
It doesn't look like your document viewer is part of your xaml file. It looks like you are creating a new DocumentViewer object, but never adding it to the xaml file.
Instead of
Declare it in your xaml file: