When I read books about WPF, I saw the authors mention XPS like it was something important. Windows also includes its XPS viewer, and I've seen that listed as a "feature" of Windows.
当我阅读有关WPF的书籍时,我看到作者提到XPS就像它是重要的东西。 Windows还包括其XPS查看器,我已经看到它被列为Windows的“功能”。
But why? What's the point? Who the heck uses it? It's my understanding that XPS is, basically, like PDF, xhtml, or ePub (which is just xhtml)...or even Word's docx format. Many of the features are the same among those formats.
但为什么?重点是什么?谁用它呢?据我所知,XPS基本上就像PDF,xhtml或ePub(只是xhtml)......甚至是Word的docx格式。这些格式中的许多功能都是相同的。
It doesn't seem to have any major benefits compared to any of those other formats. It seems to me that xhtml would be so much more useful than XPS as a way to save and load FlowDocuments from the RichTextBox. I've looked at multiple blogs about converting between the two. Most or all of the rich text on the internet is (x)html. Beyond that, I don't think anyone uses it just to publish their docs; PDF is preferred. It seems like XPS is just some random format that MS made and decided to push. I generally love MS, but they do have a habit of that kind of thing. Couldn't MS have made an api using xhtml instead? That would have been more useful in a lot of situations, I'd think.
与任何其他格式相比,它似乎没有任何重大好处。在我看来,xhtml作为一种从RichTextBox保存和加载FlowDocuments的方法比XPS更有用。我看过多个关于两者之间转换的博客。互联网上的大部分或全部富文本都是(x)html。除此之外,我认为没有人只是用它来发布他们的文档; PDF是首选。似乎XPS只是MS制作并决定推出的一些随机格式。我一般都喜欢MS,但他们确实有这种习惯。 MS不能使用xhtml制作api吗?我想,在很多情况下,这会更有用。
So, is there a point to using XPS, particularly in comparison to one of the other formats I mentioned (or any I haven't)? Have you ever used XPS in your programs or otherwise?
那么,有没有必要使用XPS,特别是与我提到的其他格式(或任何我没有)相比较?你有没有在你的程序中使用过XPS?
7 个解决方案
#1
8
As U62 already stated, WPF comes with a DocumentViewer control which enables you to view XPS documents. The DocumentViewer also has some useful fonctions like Print, Zoom, FitToPage etc... So you don't need to implement that or use a third party tool.
正如U62已经说过的,WPF附带了一个DocumentViewer控件,可以让您查看XPS文档。 DocumentViewer还有一些有用的功能,如Print,Zoom,FitToPage等......所以你不需要实现它或使用第三方工具。
What I just finished an hour ago using XPS and the DocumentViewer was some kind of "Adress label print preview". Allow the user to select some contacts from a list of contacts, click "Print Preview". This opens a new XAML Window which contains a DocumentViewer control and a ListBox with the choice of different Labels (e.g. 1 sheet with 12 labels [2 columns, 6 rows], 1 sheet with a single label whose width and height can be user defined). Based on the users selection, I generate an XPS Document in the layout the user selected with the adresses of the selected contacts. If e.g. the user selected 4 contacts and wishes to print them on "SingleLabelSheet"'s, I generate 1 XPS document with 4 pages, each page containing 1 Adress. Then I display the XPS in the DocumentViewer and the user can print the labels on our Label Printer.
我刚刚在一小时前使用XPS和DocumentViewer完成的是某种“Adress标签打印预览”。允许用户从联系人列表中选择一些联系人,单击“打印预览”。这将打开一个新的XAML窗口,其中包含一个DocumentViewer控件和一个ListBox,可以选择不同的标签(例如,1张带有12个标签[2列,6行],1张带有单个标签,其宽度和高度可以由用户定义) 。根据用户选择,我在用户使用所选联系人的地址选择的布局中生成XPS文档。如果是用户选择了4个联系人并希望在“SingleLabelSheet”上打印它们,我生成1个XPS文档,包含4个页面,每个页面包含1个地址。然后我在DocumentViewer中显示XPS,用户可以在我们的标签打印机上打印标签。
Once I understood how the XPS API worked (at least the Basics), it was a matter of 2 hours to get this up and running.
一旦我理解了XPS API的工作原理(至少是基础知识),启动和运行它需要2个小时。
So, basically, I see XPS as an easy to use API to display FixedDocuments which are to be generated on the fly. But I wouldn't personnally go about saving them to my HDD or somehow modify them or whatever you generally do with documents.
所以,基本上,我认为XPS是一个易于使用的API,可以显示即时生成的FixedDocuments。但我个人不会将它们保存到我的硬盘驱动器上,或以某种方式修改它们或者你通常用文件做的任何事情。
#2
3
The only actual advantage I can think of is that you have a control for viewing XPS documents in WPF applications. The other formats you mention mean you would have to bring in a 3rd party renderer (or write one yourself if you have a year to spare).
我能想到的唯一实际优势是您可以在WPF应用程序中查看XPS文档。您提到的其他格式意味着您必须引入第三方渲染器(如果您有一年的备用,则自行编写一个)。
btw. I don't know much about ePub, but XPS isn't directly comparable with XHTML, it's more like PDF in that it's designed to have a fixed layout.
顺便说一句。我对ePub了解不多,但XPS与XHTML无法直接比较,它更像PDF,因为它的设计具有固定的布局。
#3
3
XPS to WPF is like WMF to Win32/WinForms, it's a persistent format that let you store and print native WPF graphics.
XPS到WPF就像WMF到Win32 / WinForms,它是一种持久的格式,可以存储和打印本机WPF图形。
XPS is used to print from WPF (even when you print directly from the application without saving, the internal printing system is built on XPS) so what should MS do:
XPS用于从WPF打印(即使直接从应用程序打印而不保存,内部打印系统也是基于XPS构建的)所以MS应该做什么:
- Create a new file format that exactly fit with what they are trying to do
- 创建一个完全符合他们尝试的新文件格式
- Build a 100% perfect translator from WPF to a format they don't control like PDF (and hope Adobe doesn't break all WPF applications out there with the next release of Acrobat Reader).
- 从WPF构建一个100%完美的翻译器,他们不像PDF那样控制的格式(并希望Adobe不会在下一版本的Acrobat Reader中破坏所有WPF应用程序)。
What would you do?
你会怎么做?
Saving XPS files is just a nice bonus.
保存XPS文件只是一个很好的奖励。
#4
3
Look, I may be a pessimist on XPS as a report generation solution, but I gave it a go and found the initial documentation to be hard to understand, with less real world samples out there than what I would have liked. When I put it into a real world business application I found it to be frustrating, particularly in LOB apps that require tables that span over multiple pages.
看,我可能是XPS作为报告生成解决方案的悲观主义者,但我试了一下,发现最初的文档难以理解,其中的真实世界样本比我想要的少。当我把它放入一个真实的商业应用程序时,我发现它令人沮丧,特别是在需要跨越多个页面的表的LOB应用程序中。
Things may have changed since then but as soon as I started looking at tables that spanned over several pages and I wanted column headers to go to the top, etc. I found that the API required me to do what I would call excessive workarounds with unnecessary complexity.
从那时起事情可能发生了变化,但是一旦我开始查看跨越多个页面的表格,我希望列标题出现在顶部,等等。我发现API要求我做我称之为过多的不必要的变通方法。复杂。
So, things may have changed since then (about 8 months ago), but I went from XPS to using ITextSharp and that has been a lot less painful.
因此,事情可能已经发生了变化(大约8个月前),但是我从XPS转到使用ITextSharp,这已经不那么痛苦了。
So the only advantage I would say, like everyone else, is the built in viewer in WPF - but other than that I feel the API may need to "mature" a bit more before I will attempt something again in it.
因此,与其他人一样,我所说的唯一优势就是WPF内置的查看器 - 但除此之外,我觉得API可能需要“成熟”一点,然后再尝试一下它。
#5
2
Actually I found a really nice reason to use XPS. I wanted to print from multiple sources, merge documents and specify duplex and stapled. Finally it should be printed as one document with duplex and stapled. I was having a difficult time doing so but found that by printing to XPS (saved to disc) I could accomplish my goal with minimum fuss. I haven't found any other method that is so easy and straightforward.
实际上我找到了使用XPS的一个非常好的理由。我想从多个来源打印,合并文档并指定双面打印和装订。最后,它应打印为一个双面和装订的文件。我很难这样做,但发现通过打印到XPS(保存到光盘),我可以用最小的麻烦完成我的目标。我还没有找到任何其他简单明了的方法。
Dim PrintServer As New SysPrint.PrintServer("\\" & My.Computer.Name)
Dim PrintQ As New SysPrint.PrintQueue(PrintServer, "Ricoh Main")
Dim Jobs As SysPrint.PrintJobInfoCollection = PrintQ.GetPrintJobInfoCollection
Dim able As SysPrint.PrintCapabilities = PrintQ.GetPrintCapabilities()
Dim CurrentTicket As SysPrint.PrintTicket = PrintQ.CurrentJobSettings.CurrentPrintTicket
If able.StaplingCapability IsNot Nothing AndAlso able.StaplingCapability.Count > 0 Then
If able.StaplingCapability.Contains(Printing.Stapling.StapleTopLeft) Then
CurrentTicket.Stapling = Printing.Stapling.StapleTopLeft
End If
Else
Debug.Print("no stapling capability")
End If
CurrentTicket.Duplexing = Printing.Duplexing.TwoSidedLongEdge
Dim fiName As String = "S:\Temp\PS\XPS\Test.xps"
Dim TestJob As SysPrint.PrintSystemJobInfo _
= PrintQ.AddJob("Test job", fiName, False)
#6
1
XPS (code named "metro") was clearly designed as the Microsoft alternative to PDF and PostScript in Windows Vista. See this old article here: Microsoft Readies New Document Printing Specification
XPS(代号为“metro”)显然被设计为Windows Vista中PDF和PostScript的Microsoft替代品。请参阅此处的旧文章:Microsoft准备新文档打印规范
#7
0
There are different approches when inventing document formats:
在发明文档格式时有不同的方法:
- Some are made for quick view on screen (say low def) like HTML, doc.
- 有些是为了快速查看屏幕(比如低def),如HTML,doc。
- Some other are (or can be) very respectuous of printing contrains (say quality based) like PDF, XPS.
- 其他一些(或可能)非常尊重印刷禁令(比如基于质量),如PDF,XPS。
So XPS whiches to be as good as PDF, plus it is formated in XML, so "maybe" it is more standard than the stream approch in PDF.
因此,XPS与PDF一样好,而且它是用XML格式化的,所以“可能”它比PDF格式的流程更加标准化。
The black spot of XPS is maybe the management of special colors (Pantone, paper effects).
XPS的黑点可能是特殊颜色的管理(Pantone,纸张效果)。
#1
8
As U62 already stated, WPF comes with a DocumentViewer control which enables you to view XPS documents. The DocumentViewer also has some useful fonctions like Print, Zoom, FitToPage etc... So you don't need to implement that or use a third party tool.
正如U62已经说过的,WPF附带了一个DocumentViewer控件,可以让您查看XPS文档。 DocumentViewer还有一些有用的功能,如Print,Zoom,FitToPage等......所以你不需要实现它或使用第三方工具。
What I just finished an hour ago using XPS and the DocumentViewer was some kind of "Adress label print preview". Allow the user to select some contacts from a list of contacts, click "Print Preview". This opens a new XAML Window which contains a DocumentViewer control and a ListBox with the choice of different Labels (e.g. 1 sheet with 12 labels [2 columns, 6 rows], 1 sheet with a single label whose width and height can be user defined). Based on the users selection, I generate an XPS Document in the layout the user selected with the adresses of the selected contacts. If e.g. the user selected 4 contacts and wishes to print them on "SingleLabelSheet"'s, I generate 1 XPS document with 4 pages, each page containing 1 Adress. Then I display the XPS in the DocumentViewer and the user can print the labels on our Label Printer.
我刚刚在一小时前使用XPS和DocumentViewer完成的是某种“Adress标签打印预览”。允许用户从联系人列表中选择一些联系人,单击“打印预览”。这将打开一个新的XAML窗口,其中包含一个DocumentViewer控件和一个ListBox,可以选择不同的标签(例如,1张带有12个标签[2列,6行],1张带有单个标签,其宽度和高度可以由用户定义) 。根据用户选择,我在用户使用所选联系人的地址选择的布局中生成XPS文档。如果是用户选择了4个联系人并希望在“SingleLabelSheet”上打印它们,我生成1个XPS文档,包含4个页面,每个页面包含1个地址。然后我在DocumentViewer中显示XPS,用户可以在我们的标签打印机上打印标签。
Once I understood how the XPS API worked (at least the Basics), it was a matter of 2 hours to get this up and running.
一旦我理解了XPS API的工作原理(至少是基础知识),启动和运行它需要2个小时。
So, basically, I see XPS as an easy to use API to display FixedDocuments which are to be generated on the fly. But I wouldn't personnally go about saving them to my HDD or somehow modify them or whatever you generally do with documents.
所以,基本上,我认为XPS是一个易于使用的API,可以显示即时生成的FixedDocuments。但我个人不会将它们保存到我的硬盘驱动器上,或以某种方式修改它们或者你通常用文件做的任何事情。
#2
3
The only actual advantage I can think of is that you have a control for viewing XPS documents in WPF applications. The other formats you mention mean you would have to bring in a 3rd party renderer (or write one yourself if you have a year to spare).
我能想到的唯一实际优势是您可以在WPF应用程序中查看XPS文档。您提到的其他格式意味着您必须引入第三方渲染器(如果您有一年的备用,则自行编写一个)。
btw. I don't know much about ePub, but XPS isn't directly comparable with XHTML, it's more like PDF in that it's designed to have a fixed layout.
顺便说一句。我对ePub了解不多,但XPS与XHTML无法直接比较,它更像PDF,因为它的设计具有固定的布局。
#3
3
XPS to WPF is like WMF to Win32/WinForms, it's a persistent format that let you store and print native WPF graphics.
XPS到WPF就像WMF到Win32 / WinForms,它是一种持久的格式,可以存储和打印本机WPF图形。
XPS is used to print from WPF (even when you print directly from the application without saving, the internal printing system is built on XPS) so what should MS do:
XPS用于从WPF打印(即使直接从应用程序打印而不保存,内部打印系统也是基于XPS构建的)所以MS应该做什么:
- Create a new file format that exactly fit with what they are trying to do
- 创建一个完全符合他们尝试的新文件格式
- Build a 100% perfect translator from WPF to a format they don't control like PDF (and hope Adobe doesn't break all WPF applications out there with the next release of Acrobat Reader).
- 从WPF构建一个100%完美的翻译器,他们不像PDF那样控制的格式(并希望Adobe不会在下一版本的Acrobat Reader中破坏所有WPF应用程序)。
What would you do?
你会怎么做?
Saving XPS files is just a nice bonus.
保存XPS文件只是一个很好的奖励。
#4
3
Look, I may be a pessimist on XPS as a report generation solution, but I gave it a go and found the initial documentation to be hard to understand, with less real world samples out there than what I would have liked. When I put it into a real world business application I found it to be frustrating, particularly in LOB apps that require tables that span over multiple pages.
看,我可能是XPS作为报告生成解决方案的悲观主义者,但我试了一下,发现最初的文档难以理解,其中的真实世界样本比我想要的少。当我把它放入一个真实的商业应用程序时,我发现它令人沮丧,特别是在需要跨越多个页面的表的LOB应用程序中。
Things may have changed since then but as soon as I started looking at tables that spanned over several pages and I wanted column headers to go to the top, etc. I found that the API required me to do what I would call excessive workarounds with unnecessary complexity.
从那时起事情可能发生了变化,但是一旦我开始查看跨越多个页面的表格,我希望列标题出现在顶部,等等。我发现API要求我做我称之为过多的不必要的变通方法。复杂。
So, things may have changed since then (about 8 months ago), but I went from XPS to using ITextSharp and that has been a lot less painful.
因此,事情可能已经发生了变化(大约8个月前),但是我从XPS转到使用ITextSharp,这已经不那么痛苦了。
So the only advantage I would say, like everyone else, is the built in viewer in WPF - but other than that I feel the API may need to "mature" a bit more before I will attempt something again in it.
因此,与其他人一样,我所说的唯一优势就是WPF内置的查看器 - 但除此之外,我觉得API可能需要“成熟”一点,然后再尝试一下它。
#5
2
Actually I found a really nice reason to use XPS. I wanted to print from multiple sources, merge documents and specify duplex and stapled. Finally it should be printed as one document with duplex and stapled. I was having a difficult time doing so but found that by printing to XPS (saved to disc) I could accomplish my goal with minimum fuss. I haven't found any other method that is so easy and straightforward.
实际上我找到了使用XPS的一个非常好的理由。我想从多个来源打印,合并文档并指定双面打印和装订。最后,它应打印为一个双面和装订的文件。我很难这样做,但发现通过打印到XPS(保存到光盘),我可以用最小的麻烦完成我的目标。我还没有找到任何其他简单明了的方法。
Dim PrintServer As New SysPrint.PrintServer("\\" & My.Computer.Name)
Dim PrintQ As New SysPrint.PrintQueue(PrintServer, "Ricoh Main")
Dim Jobs As SysPrint.PrintJobInfoCollection = PrintQ.GetPrintJobInfoCollection
Dim able As SysPrint.PrintCapabilities = PrintQ.GetPrintCapabilities()
Dim CurrentTicket As SysPrint.PrintTicket = PrintQ.CurrentJobSettings.CurrentPrintTicket
If able.StaplingCapability IsNot Nothing AndAlso able.StaplingCapability.Count > 0 Then
If able.StaplingCapability.Contains(Printing.Stapling.StapleTopLeft) Then
CurrentTicket.Stapling = Printing.Stapling.StapleTopLeft
End If
Else
Debug.Print("no stapling capability")
End If
CurrentTicket.Duplexing = Printing.Duplexing.TwoSidedLongEdge
Dim fiName As String = "S:\Temp\PS\XPS\Test.xps"
Dim TestJob As SysPrint.PrintSystemJobInfo _
= PrintQ.AddJob("Test job", fiName, False)
#6
1
XPS (code named "metro") was clearly designed as the Microsoft alternative to PDF and PostScript in Windows Vista. See this old article here: Microsoft Readies New Document Printing Specification
XPS(代号为“metro”)显然被设计为Windows Vista中PDF和PostScript的Microsoft替代品。请参阅此处的旧文章:Microsoft准备新文档打印规范
#7
0
There are different approches when inventing document formats:
在发明文档格式时有不同的方法:
- Some are made for quick view on screen (say low def) like HTML, doc.
- 有些是为了快速查看屏幕(比如低def),如HTML,doc。
- Some other are (or can be) very respectuous of printing contrains (say quality based) like PDF, XPS.
- 其他一些(或可能)非常尊重印刷禁令(比如基于质量),如PDF,XPS。
So XPS whiches to be as good as PDF, plus it is formated in XML, so "maybe" it is more standard than the stream approch in PDF.
因此,XPS与PDF一样好,而且它是用XML格式化的,所以“可能”它比PDF格式的流程更加标准化。
The black spot of XPS is maybe the management of special colors (Pantone, paper effects).
XPS的黑点可能是特殊颜色的管理(Pantone,纸张效果)。