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

Table - Text Font Size

2 Answers 610 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Janice
Top achievements
Rank 1
Janice asked on 10 Aug 2015, 10:16 PM

Hello,

I am struggling setting the Font Size of all the Text in my Table that i am drawing inside of my pdf document.  It seems like it is defaulting to either 10 or 12... I need to display at least 4 columns in a row, and i want to reduce the font size to at least 8.  Is there any way to do this without setting up a unique block each time and then trying to add it to Cell, and Row , etc...

 

My code looks like this below:

---------------------------------------------------------------------------------------------------------------------------------------------------------

 Dim RevenueTable As New Table()

   Dim firstRow As TableRow = RevenueTable.Rows.AddTableRow()

            firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("---------------------------")
            firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("--------------------SERVICE")
            firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText(" DETAILS-------------------")
            firstRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("---------------------------")

            Dim secondRow As TableRow = RevenueTable.Rows.AddTableRow()
            secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText(objReceipt.SERVCODE(i))
            secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText(objReceipt.SERVNAME(i))
            secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText(objReceipt.SERVQTY(i))
            secondRow.Cells.AddTableCell().Blocks.AddBlock().InsertText("")

            Dim ServiceCodeRowDesc As TableRow = RevenueTable.Rows.AddTableRow()
            ServiceCodeRowDesc.Cells.AddTableCell().Blocks.AddBlock().InsertText("Revenue Desc")
            ServiceCodeRowDesc.Cells.AddTableCell().Blocks.AddBlock().InsertText("Item Price")
            ServiceCodeRowDesc.Cells.AddTableCell().Blocks.AddBlock().InsertText("Qty")
            ServiceCodeRowDesc.Cells.AddTableCell().Blocks.AddBlock().InsertText("Revenue Amount")

 {....lines of code removed ....}

 editor.TextProperties.FontSize = 8
  editor.DrawTable(RevenueTable)

------------------------------------------------------------------------------------------------------------------------------------------------ 

The font size is not 8.

2 Answers, 1 is accepted

Sort by
0
Janice
Top achievements
Rank 1
answered on 11 Aug 2015, 06:19 PM

Basically I am trying to do this, but with the code above and not the code below:)

Dim table As New Table()
        Dim firstRow As TableRow = table.Rows.AddTableRow()
        Dim firstCell As TableCell = firstRow.Cells.AddTableCell()
        Dim firstBlock As Block = firstCell.Blocks.AddBlock()

        firstBlock.TextProperties.FontSize = 8
        firstBlock.InsertText("-----------------------------------------")

        Dim secondCell As TableCell = firstRow.Cells.AddTableCell()
        Dim secondBlock As Block = secondCell.Blocks.AddBlock()

        secondBlock.TextProperties.FontSize = 8
        secondBlock.InsertText("-----------SERVICE DETAILS--------------")

        Dim thirdCell As TableCell = firstRow.Cells.AddTableCell()
        Dim thirdBlock As Block = thirdCell.Blocks.AddBlock()

        thirdBlock.TextProperties.FontSize = 8
        thirdBlock.InsertText("----------------------------------------")

        Dim secondRow As TableRow = table.Rows.AddTableRow()

        Dim fourthCell As TableCell = secondRow.Cells.AddTableCell()
        Dim fourthBlock As Block = fourthCell.Blocks.AddBlock()

        fourthBlock.TextProperties.FontSize = 8
        fourthBlock.InsertText("Apple")

        Dim fifthCell As TableCell = secondRow.Cells.AddTableCell()
        Dim fifthBlock As Block = fifthCell.Blocks.AddBlock()

        fifthBlock.TextProperties.FontSize = 8
        fifthBlock.InsertText("Orange")

        Dim sixthCell As TableCell = secondRow.Cells.AddTableCell()
        Dim sixthBlock As Block = sixthCell.Blocks.AddBlock()

        sixthBlock.TextProperties.FontSize = 8
        sixthBlock.InsertText("Peach")

        table.LayoutType = TableLayoutType.AutoFit
        editor.DrawTable(table)

0
Petya
Telerik team
answered on 13 Aug 2015, 02:53 PM
Hi Janice,

Modifying the properties of the blocks inside a table through the FixedContentEditor is not possible, so I'm afraid I cannot provide an alternative to the code in your latest post. A Block is practically an editor on its own and it has its own set of properties. In fact, the two classes derive the same base - FixedContentEditorBase.

The only option I could suggest is to set the FontSize for each block inside the table.

Regards,
Petya
Telerik
Tags
PdfProcessing
Asked by
Janice
Top achievements
Rank 1
Answers by
Janice
Top achievements
Rank 1
Petya
Telerik team
Share this question
or