Если кто-то интересуется кодом VB:
Public Sub CreateXPSStream(targetDocument As String, ListToMerge As List(Of String))
If (File.Exists(targetDocument)) Then
File.Delete(targetDocument)
End If
Dim container As Package = Package.Open(targetDocument, FileMode.Create)
Dim xpsDoc = New System.Windows.Xps.Packaging.XpsDocument(container)
Dim seqNew As FixedDocumentSequence = New FixedDocumentSequence()
For Each sourceDocument As String In ListToMerge
AddXPSDocuments(sourceDocument, seqNew)
Next
Dim xpsWriter As XpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(xpsDoc)
xpsWriter.Write(seqNew)
xpsDoc.Close()
container.Close()
End Sub
Public Sub AddXPSDocuments(ByVal sourceDocument As String, ByRef seqNew As FixedDocumentSequence)
Try
Dim xpsOld As XpsDocument = New XpsDocument(sourceDocument, FileAccess.Read)
Dim seqOld As FixedDocumentSequence = xpsOld.GetFixedDocumentSequence()
For Each r As DocumentReference In seqOld.References
Dim newRef As DocumentReference = New DocumentReference()
CType(newRef, IUriContext).BaseUri = CType(r, IUriContext).BaseUri
newRef.Source = r.Source
seqNew.References.Add(newRef)
Next
Catch ex As Exception
myStatusAdd("Error with " & sourceDocument)
End Try
End Sub
спасибо за начальный код.
Это также требует значительного количества ссылок в ваших проектах:
PresentationCore
PresentationFramework
ReachFramwork
System.Core
System.Windows.Presentation
System.Xaml
System.Printing
WindowsBase
Я думаю, что это все.