Can't change default font size on pdf export?

3 posts, 0 answers
  1. Clive Hoggar
    Clive Hoggar avatar
    337 posts
    Member since:
    Nov 2008

    Posted 08 Feb Link to this post

    Hi

    I am exporting a grid to pdf following various examples, and I am using the RadGrid_ItemCreated event successfully to have alternating row styles but I haven't found any way to set the font size.

    Existing code is :

     

     Protected Sub FormatGridItem(item As GridItem)
            If TypeOf item Is GridHeaderItem Then
                For Each cell As TableCell In item.Cells
                    cell.Style("font-family") = "Arial"
                    cell.Style("text-align") = "left"
                    cell.Style("vertical-align") = "middle"
                Next
            End If

            ' Dim dataItems As GridItem() = View.GetItems(GridItemType.Item)
            If TypeOf item Is GridDataItem Then
                item.Style("Font-family") = "Arial"
            Select Case item.ItemType

                    Case GridItemType.Item
                        item.Style("background-color") = "#DDDDDD"
                        item.Style("Font-size") = "10pt"  ' no effect
                        Exit Select
                    Case GridItemType.AlternatingItem
                        item.Style("background-color") = "#FFFFFF"
                        item.Style("Font-size") = "10pt"  ' no effect
                        Exit Select
                    Case GridItemType.Header
                        item.Font.Bold = True
                        Exit Select
                    Case GridItemType.Footer
                        item.Style("background-color") = "#FFFFFF"
                        Exit Select
                End Select
            End If
        End Sub

     

    how can I set the font size? I have tried using px, pt, and em but it does not change.

    Please advise. I haven't seen any code on this; maybe it is not possible or has to be done somewhere else entirely.

     

    Thanks

     

    Clive

     

  2. Rumen
    Admin
    Rumen avatar
    12945 posts

    Posted 10 Feb Link to this post

    Hello Clive,

    I modified the code of the Export to PDF grid demo by adding this line

    item.Style("font-size") = "5px" in the FormatGridItem function and it formatted as expected the font in the generated PDF file.

    For your convenience, I recorded a video demonstrating my test: https://www.screencast.com/t/24XNsfWiEeaj

    Best regards,
    Rumen
    Telerik by Progress
    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.
  3. Clive Hoggar
    Clive Hoggar avatar
    337 posts
    Member since:
    Nov 2008

    Posted 10 Feb in reply to Rumen Link to this post

    Thanks for your help.

    I am using alternating row background colour for the grid and I had to put the item.style code in both GridItemType.Item and GridItemType.AlternatingItem to make it work:

    Select Case item.ItemType

                  Case GridItemType.Item

                      item.Style("background-color") = "#DDDDDD"

         item.Style("Font-size") = "0.8em"

                        Exit Select
                    Case GridItemType.AlternatingItem
                        item.Style("background-color") = "#FFFFFF"
                        item.Style("Font-size") = "0.8em"
                        Exit Select
                    Case GridItemType.Header
                        item.Font.Bold = True
                        Exit Select
                    Case GridItemType.Footer
                        item.Style("background-color") = "#FFFFFF"
                        Exit Select
                End Select

     

     

Back to Top