本文整理汇总了VB.NET中System.IO.Packaging.PackageStore.GetPackage方法的典型用法代码示例。如果您正苦于以下问题:VB.NET PackageStore.GetPackage方法的具体用法?VB.NET PackageStore.GetPackage怎么用?VB.NET PackageStore.GetPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了PackageStore.GetPackage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: OpenDocument
' --------------------------- OpenDocument ---------------------------
''' <summary>
''' Loads and displays a given XPS document file.</summary>
''' <param name="filename">
''' The path and file name of the XPS
''' document to load and display.</param>
''' <returns>
''' true if the document loads successfully; otherwise false.</returns>
Public Function OpenDocument(ByVal xpsFile As String) As Boolean
' Check to see if the document is encrypted.
' If encrypted, use OpenEncryptedDocument().
If EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(xpsFile) Then
Return OpenEncryptedDocument(xpsFile)
End If
' Document is not encrypted, open normally.
ShowStatus("Opening '" & Filename(xpsFile) & "'")
_packageUri = New Uri(xpsFile, UriKind.Absolute)
Try
_xpsDocument = New XpsDocument(xpsFile, FileAccess.Read)
Catch ex As System.IO.FileFormatException
MessageBox.Show(xpsFile & vbLf & vbLf & "The file " & "is not a valid XPS document." & vbLf & vbLf & "Exception: " & ex.Message & vbLf & vbLf & ex.GetType().ToString() & vbLf & vbLf & ex.StackTrace, "Invalid File Format", MessageBoxButton.OK, MessageBoxImage.Error)
Return False
End Try
' Get the document's PackageStore into which
' new user annotations will be added and saved.
_xpsPackage = PackageStore.GetPackage(_packageUri)
If (_xpsPackage Is Nothing) OrElse (_xpsDocument Is Nothing) Then
MessageBox.Show("Unable to get Package from file.")
Return False
End If
' Get the FixedDocumentSequence from the open document.
Dim fds As FixedDocumentSequence = _xpsDocument.GetFixedDocumentSequence()
If fds Is Nothing Then
MessageBox.Show(xpsFile & vbLf & vbLf & "The document package within " & "the specified file does not contain a " & "FixedDocumentSequence.", "Package Error")
Return False
End If
' Load the FixedDocumentSequence to the DocumentViewer control.
DocViewerProperty.Document = fds
' Enable document menu controls.
menuFileClose.IsEnabled = True
menuFilePrint.IsEnabled = True
menuViewIncreaseZoom.IsEnabled = True
menuViewDecreaseZoom.IsEnabled = True
' Give the DocumentViewer focus.
docViewer.Focus()
Me.Title = "RightsManagedPackageViewer SDK Sample - " & Filename(xpsFile)
Return True
End Function ' end:OpenDocument()
开发者ID:VB.NET开发者,项目名称:System.IO.Packaging,代码行数:57,代码来源:PackageStore.GetPackage
注:本文中的System.IO.Packaging.PackageStore.GetPackage方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论