Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I did it in this way:</p> <pre><code>Private Sub ExportToImage() Dim flowDoc As New FlowDocument flowDoc.FontFamily = New FontFamily("Arial") flowDoc.PageWidth = 826 flowDoc.PageHeight = 1152 flowDoc.ColumnWidth = "999999" 'To fill the whole page flowDoc.PagePadding = New Thickness(48) ' Dim myTable As New Table myTable.FontSize = 12 myTable.Padding = New Thickness(0) myTable.CellSpacing = 0 myTable.TextAlignment = TextAlignment.Center myTable.BorderThickness = New Thickness(1) myTable.BorderBrush = CType(New BrushConverter().ConvertFrom("#ccc"), SolidColorBrush) myTable.Background = CType(New BrushConverter().ConvertFrom("#eaebec"), SolidColorBrush) For x As Integer = 0 To 6 myTable.Columns.Add(New TableColumn()) Next ' Create and add an empty TableRowGroup to hold the table's Rows. myTable.RowGroups.Add(New TableRowGroup()) ' Add the first (title) row. myTable.RowGroups(0).Rows.Add(New TableRow()) Dim currentRow As New TableRow() currentRow = myTable.RowGroups(0).Rows(0) Dim view As GridView = MyListView.View Dim nColCount As Integer = view.Columns.Count currentRow.Background = CType(New BrushConverter().ConvertFrom("#ededed"), SolidColorBrush) currentRow.FontWeight = FontWeights.Bold For i As Integer = 0 To nColCount - 1 ' Add the header row with content Dim cellH As New TableCell cellH.Padding = New Thickness(6) cellH.Blocks.Add(New Paragraph(New Run(GetHeader(view, i)))) currentRow.Cells.Add(cellH) Next Dim nItemsCount As Integer = GetItemsCount() For i As Integer = 0 To nItemsCount - 1 myTable.RowGroups(0).Rows.Add(New TableRow()) currentRow = myTable.RowGroups(0).Rows(i + 1) currentRow.Cells.Add(New Paragraph(New Run(new Class Instance)) Next flowDoc.Blocks.Add(myTable) Dim fdSize As Size = New Size(flowDoc.PageWidth, flowDoc.PageHeight) Dim paginator = (CType(flowDoc, IDocumentPaginatorSource)).DocumentPaginator paginator.PageSize = fdSize Dim visual = New DrawingVisual Using drawingtext As DrawingContext = visual.RenderOpen drawingtext.DrawRectangle(Brushes.White, Nothing, New Rect(fdSize)) End Using visual.Children.Add(paginator.GetPage(0).Visual) vis = visual rtb = New RenderTargetBitmap(fdSize.Width, fdSize.Height, 96, 96, PixelFormats.Pbgra32) rtb.Render(visual) Dim bmpEncoder As BmpBitmapEncoder = New BmpBitmapEncoder bmpEncoder.Frames.Add(BitmapFrame.Create(rtb)) Using stream As FileStream = New FileStream("Image.bmp", FileMode.Create) bmpEncoder.Save(stream) End Using End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload