Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Style Individual Table Cells
  FAQ FAQ  Forum Search   Register Register  Login Login

Style Individual Table Cells

 Post Reply Post Reply
Author
Message
chris_adsi View Drop Down
Team Player
Team Player


Joined: 19 May 21
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote chris_adsi Quote  Post ReplyReply Direct Link To This Post Topic: Style Individual Table Cells
    Posted: 25 Jan 22 at 12:22PM
Hi

I am drawing tables onto my document, and I am struggling to format individual table cells.

Ideally I want to make my header/ footers bold text. I have tried just using html bold tags but this does not seem to work with the selected font, which is Century Gothic. Elsewhere in my document when I was to render the font as bold I actually select Century Gothic Bold as the font.

I have tried putting some code in to select the font on a cell by cell basis but that only seems to format the entire table as bold, not individual cells.

With the default font (Arial?) the bold html tags do seem to work.

Any ideas how I can get formatting control with a specific font please?
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jan 22 at 10:48PM
Hi Chris,


i don't know what you've read here in the forum and in the resources so far...
It would be good to see your code (a snippet with the table-syntax) to help.

Here's a thread with a good sample from Rowan:
http://www.quickpdf.org/forum/create-table-exactly-like-this-sample_topic1907.html

Here's a kb-article about how to insert a table into a pdf:
https://www.debenu.com/kb/insert-table-pdf/

Starting your search from here could give you many more results and help:
https://www.debenu.com/docs/pdf_library_reference/Search.php

Cheers,
Ingo

Back to Top
chris_adsi View Drop Down
Team Player
Team Player


Joined: 19 May 21
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote chris_adsi Quote  Post ReplyReply Direct Link To This Post Posted: 26 Jan 22 at 8:34AM
Hi Ingo

Funnily enough it was exactly that first link where I started!

I hadn't seen that second one so wasn't familiar with the concept of the NormalFont BoldFont etc concept - that looks like it may well be what I need so will give it a try. 

This is my code :

    Set flds = FetchDocFields(lngType, lngSect, strUser, 1)
    
    lngFont = objPDF.AddTrueTypeFont(doc.FontName, 0)
    lngRes = objPDF.SelectFont(lngFont)
    'set to default for the table
    lngRes = objPDF.SetHTMLNormalFont("Default", lngFont)
    
    'how many rows?
    For Each fld In flds
        If fld.FieldType = FieldType.Table Then 'table level settings
            colms = fld.DrawOptions
            strBordColour = fld.BorderColour
            dblBordWidth = fld.BorderWidth
        End If
        If fld.FieldType = FieldType.TableRow Then
            rows = rows + 1
        End If
    Next
        
    'create the table skeleton
    lngTable = objPDF.CreateTable(rows, colms)
    
    'Specify color and width of table borders
    If strBordColour <> "" Then
        lngRes = objPDF.SetTableBorderColor(lngTable, 0, GetColourRGB(strBordColour, 0), GetColourRGB(strBordColour, 1), GetColourRGB(strBordColour, 2))
        lngRes = objPDF.SetTableThinBorders(lngTable, 1, GetColourRGB(strBordColour, 0), GetColourRGB(strBordColour, 1), GetColourRGB(strBordColour, 2))
    End If
    If dblBordWidth > 0 Then
        lngRes = objPDF.SetTableBorderWidth(lngTable, 0, dblBordWidth)
    End If
    
    'Specify table row height
    lngRes = objPDF.SetTableRowHeight(lngTable, 1, rows, 0)

    For Each fld In flds
    
        Select Case fld.FieldType
            
            Case FieldType.TableRow
                'resest
                row = row + 1
                ColM = 1
                If fld.Height > 0 Then
                    'Specify row height
                    lngRes = objPDF.SetTableRowHeight(lngTable, row, row, fld.Height)
                End If
                
            Case FieldType.TableCell
                'render cell
                'width
                lngRes = objPDF.SetTableColumnWidth(lngTable, ColM, ColM, fld.Width)
                'alignment
                lngRes = objPDF.SetTableCellAlignment(lngTable, 1, ColM, row, ColM, fld.Alignment)
                'Font Size
                If fld.FontSize > 0 Then
                    lngRes = objPDF.SetTableCellTextSize(lngTable, row, ColM, row, ColM, fld.FontSize)
                End If
                'Border Colour
                If fld.BorderColour <> "" Then
                    lngRes = objPDF.SetTableCellBorderColor(lngTable, row, ColM, row, ColM, 0, fld.BorderColourRGB(0), fld.BorderColourRGB(1), fld.BorderColourRGB(2))
                End If
                'border width
                If fld.BorderWidth > 0 Then
                    lngRes = objPDF.SetTableCellBorderWidth(lngTable, row, ColM, row, ColM, 0, fld.BorderWidth)
                End If
                'background fill
                If fld.BackgroundColour <> "" Then
                    lngRes = objPDF.SetTableCellBackgroundColor(lngTable, row, ColM, row, ColM, fld.BackgroundColourRGB(0), fld.BackgroundColourRGB(1), fld.BackgroundColourRGB(2))
                End If
                'forecolour
                If fld.Colour <> "" Then
                    lngRes = objPDF.SetTableCellTextColor(lngTable, row, ColM, row, ColM, fld.ColourRGB(0), fld.ColourRGB(1), fld.ColourRGB(2))
                End If
                'padding
                If fld.Padding > 0 Then
                    lngRes = objPDF.SetTableCellPadding(lngTable, row, ColM, row, ColM, 0, fld.Padding)
                Else
                    If fld.PadLeft > 0 Then
                        lngRes = objPDF.SetTableCellPadding(lngTable, row, ColM, row, ColM, 1, fld.PadLeft)
                    End If
                    If fld.PadTop > 0 Then
                        lngRes = objPDF.SetTableCellPadding(lngTable, row, ColM, row, ColM, 2, fld.PadTop)
                    End If
                    If fld.PadRight > 0 Then
                        lngRes = objPDF.SetTableCellPadding(lngTable, row, ColM, row, ColM, 3, fld.PadRight)
                    End If
                    If fld.PadBottom > 0 Then
                        lngRes = objPDF.SetTableCellPadding(lngTable, row, ColM, row, ColM, 4, fld.PadBottom)
                    End If
                End If
                'put the actual content in
                lngRes = objPDF.SetTableCellContent(lngTable, row, ColM, fld.FixedValue)
                
                ColM = ColM + 1 'increment column counter
                
        End Select
    
    Next
    
    'Draw the table onto the document
    lngRes = objPDF.DrawTableRows(lngTable, lngXPos, lngYPos, 400, 1, 0)


Back to Top
chris_adsi View Drop Down
Team Player
Team Player


Joined: 19 May 21
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote chris_adsi Quote  Post ReplyReply Direct Link To This Post Posted: 26 Jan 22 at 8:46AM
Hi Ingo (again)

The SetHTMLBoldFont did the trick - just needed to make the table row a little larger in height for some reason for it to render OK but that may be the installed fonts.

Just got to work out how to do colspan and rowspan now!

Thanks
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store