This is a migrated thread and some comments may be shown as answers.

GridView Export To PDF

1 Answer 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Cyril
Top achievements
Rank 1
Cyril asked on 08 Jun 2017, 08:06 AM

Hello,

How Draw into cell of gridview ???

Thanks for you help

My sample of code below :

Dim oRadGridView as RadGridView = new RadGridView()

Dim oPDFExporter As New GridViewPdfExport(oRadGridView)
With oPDFExporter
   AddHandler .CellFormatting, AddressOf oPDFExporter_CellFormatting
   AddHandler .CellPaint, AddressOf oPDFExporter_CellPaint
   .PageMargins = New Padding(10, 10, 10, 10)
   .ExportSettings = oPdfExportSettings
   If bLandScape Then
     .PageSize = New SizeF(297, 210)
   Else
     .PageSize = New SizeF(210, 297)
   End If
  .ShowHeaderAndFooter = True
  .FileExtension = ".pdf"
  .HiddenColumnOption = HiddenOption.DoNotExport
  .ShowHeaderAndFooter = True
  .HeaderHeight = iHeightHeader
  .HeaderFont = New System.Drawing.Font("Arial", 8, FontStyle.Regular)
  .LeftHeader = sLeftHeader
  .MiddleHeader = sMiddleHeader
  .RightHeader = sRightHeader
  .ReverseHeaderOnEvenPages = True
  .FooterHeight = 30
  .FooterFont = New System.Drawing.Font("Arial", 8, FontStyle.Regular)
  .SummariesExportOption = SummariesOption.ExportAll
  .ExportGroupedColumns = True
  .ExportHeaderRowOnEachPage = True
  '.FitToPageWidth = True
  Using oMemoryStream As New MemoryStream()
     Dim oRenderer As New PdfExportRenderer
     .RunExport(oMemoryStream, oRenderer)
     Using oFileStream As New FileStream(sPDFDocumentName, FileMode.Create, FileAccess.Write)
       oMemoryStream.WriteTo(oFileStream)
     End Using
     oRenderer = Nothing
   End Using
End With
oPdfExportSettings = Nothing
oPDFExporter = Nothing

Private Sub oPDFExporter_CellFormatting(sender As Object, e As PdfExportCellFormattingEventArgs)

End Sub

Private Sub oPDFExporter_CellPaint(sender As Object, e As ExportCellPaintEventArgs)
            Dim oPDFExporter As GridViewPdfExport = DirectCast(sender, GridViewPdfExport)
            Dim oRadGridView As RadGridView = oPDFExporter.RadGridViewToExport
            With e
                .Cell.TextWrap = True
                Dim oSize As SizeF = .Rectangle.Size
                Dim iX As Integer = .Rectangle.X + (oSize.Width - 20)
                Dim iY As Integer = .Rectangle.Y
                Select Case .Cell.ColumnIndex
                    Case "column_category"
                        If oRadGridView.Rows(e.Cell.RowIndex).Cells(13).Value = True Then
'HOW DRAW INTO CELL ?????
                            '.Cell.Graphics.DrawString("€", New System.Drawing.Font("Segoe UI", 11), Brushes.Blue, New PointF(iX, iY))
                        End If
                End Select
                oSize = Nothing
            End With
            oRadGridView = Nothing
            oPDFExporter = Nothing
End Sub

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 08 Jun 2017, 12:39 PM
Hello Cyril,

You can use the following code to draw a string:
Dim editor = TryCast(e.Editor, PdfEditor)
editor.SetFillColor(Color.Red)
editor.DrawText("Test")

Detailed information about the editor is available here: FixedContentEditor.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Cyril
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or