(t *testing.T)
| 221 | } |
| 222 | |
| 223 | func TestTableWithStyledRows(t *testing.T) { |
| 224 | // Create a new PDF document |
| 225 | pdf := &gopdf.GoPdf{} |
| 226 | // Start the PDF with a custom page size (we'll adjust it later) |
| 227 | pdf.Start(gopdf.Config{PageSize: gopdf.Rect{W: 430, H: 200}}) |
| 228 | // Add a new page to the document |
| 229 | pdf.AddPage() |
| 230 | |
| 231 | err := pdf.AddTTFFont("LiberationSerif-Regular", "./test/res/LiberationSerif-Regular.ttf") |
| 232 | if err != nil { |
| 233 | t.Fatalf("Error loading font: %v", err) |
| 234 | return |
| 235 | } |
| 236 | |
| 237 | err = pdf.SetFont("LiberationSerif-Regular", "", 11) |
| 238 | if err != nil { |
| 239 | t.Fatalf("Error set font: %v", err) |
| 240 | return |
| 241 | } |
| 242 | err = pdf.AddTTFFont("Ubuntu-L.ttf", "./examples/outline_example/Ubuntu-L.ttf") |
| 243 | if err != nil { |
| 244 | t.Fatalf("Error loading font: %v", err) |
| 245 | return |
| 246 | } |
| 247 | |
| 248 | err = pdf.SetFont("Ubuntu-L.ttf", "", 11) |
| 249 | if err != nil { |
| 250 | t.Fatalf("Error set font: %v", err) |
| 251 | return |
| 252 | } |
| 253 | |
| 254 | // Set the starting Y position for the table |
| 255 | tableStartY := 10.0 |
| 256 | // Set the left margin for the table |
| 257 | marginLeft := 10.0 |
| 258 | |
| 259 | // Create a new table layout |
| 260 | table := pdf.NewTableLayout(marginLeft, tableStartY, 25, 5) |
| 261 | |
| 262 | // Add columns to the table |
| 263 | table.AddColumn("CODE", 50, "left") |
| 264 | table.AddColumn("DESCRIPTION", 200, "left") |
| 265 | table.AddColumn("QTY.", 40, "right") |
| 266 | table.AddColumn("PRICE", 60, "right") |
| 267 | table.AddColumn("TOTAL", 60, "right") |
| 268 | |
| 269 | // Add rows to the table |
| 270 | table.AddStyledRow([]gopdf.RowCell{ |
| 271 | gopdf.NewRowCell("001", gopdf.CellStyle{ |
| 272 | TextColor: gopdf.RGBColor{R: 255, G: 0, B: 0}, |
| 273 | }), |
| 274 | gopdf.NewRowCell("Product A", gopdf.CellStyle{ |
| 275 | TextColor: gopdf.RGBColor{R: 255, G: 0, B: 0}, |
| 276 | }), |
| 277 | gopdf.NewRowCell("2", gopdf.CellStyle{ |
| 278 | TextColor: gopdf.RGBColor{R: 255, G: 0, B: 0}, |
| 279 | }), |
| 280 | gopdf.NewRowCell("10.00", gopdf.CellStyle{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…