I have this code
Private Sub SaveFixDoc(ByVal fd As FixedDocument, name As String)
Dim filename As String = My.Settings.Path2Labels & "\" & name & ".xps"
Try
Dim xpsd As XpsDocument = New XpsDocument(filename, FileAccess.ReadWrite)
Dim xpsdw As XpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(xpsd)
xpsdw.Write(fd) ' Write the FixedDocument as a document.
' ** All the way to here the fd.pages.child have my text and my images and they are rendered ok
Dim sequence As FixedDocumentSequence = xpsd.GetFixedDocumentSequence()
For pageCount As Integer = 0 To sequence.DocumentPaginator.PageCount - 1
Dim page As DocumentPage = sequence.DocumentPaginator.GetPage(pageCount)
' **but in here the page is only taking the text and completely ignoring the images they just appear as empty paths **
Dim toBitmap As New RenderTargetBitmap(4 * (CInt(page.Size.Width)), 4 * (CInt(page.Size.Height)), 384, 384, System.Windows.Media.PixelFormats.Pbgra32)
toBitmap.Render(page.Visual)
Dim bmpEncoder As JpegBitmapEncoder = New JpegBitmapEncoder()
bmpEncoder.Frames.Add(BitmapFrame.Create(toBitmap))
Dim fStream As New FileStream(My.Settings.Path2Labels & "\" & name & ".jpeg", FileMode.Create, FileAccess.Write)
bmpEncoder.Save(fStream)
fStream.Close()
Next
xpsd.Close()
Catch ex As Exception
Dim st As New StackTrace(True)
st = New StackTrace(ex, True)
Utilities.WriteToApplicationLog(New LogMessage() With {
.MessageType = "Error",
.MessageDetails = ex.ToString})
Mediator.NotifyColleagues("MessageBox", New MessageBoxObject() With {
.message =
My.Resources.mbInstrError & " SaveSingleFixedContentDocument " & " " &
st.GetFrame(0).GetFileLineNumber().ToString,
.caption = My.Resources.mbExcelError,
.button = MessageBoxButton.OK,
.image = MessageBoxImage.Error})
End Try
End Sub
fd.page.child:
page.visual:
I have change the renderer to several formats, made the render async and still the images will not load. How can I fix this?
ok, it turns out "sequence" was not getting all the data from the fixedDocument so I used the FixedDocument paginator instead