v0.0.500
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled

This commit is contained in:
2024-08-07 19:30:38 +02:00
parent 1e98d351ce
commit ab805403b9
5 changed files with 276 additions and 40 deletions

View File

@@ -2,9 +2,11 @@ package wpdf
import (
_ "embed"
"fmt"
"gogs.mikescher.com/BlackForestBytes/goext/imageext"
"gogs.mikescher.com/BlackForestBytes/goext/langext"
"os"
"path"
"testing"
)
@@ -38,7 +40,7 @@ func TestPDFBuilder(t *testing.T) {
builder.Ln(4)
cellStyleHeader := TableCellStyleOpt{
cellStyleHeader := &TableCellStyleOpt{
PDFCellOpt: *NewPDFCellOpt().
FontSize(float64(8)).
BorderColorHex(uint32(0x666666)).
@@ -48,12 +50,12 @@ func TestPDFBuilder(t *testing.T) {
TextColorHex(uint32(0x000000)).
Align(AlignHorzCenter).
Bold(),
MinWidth: langext.Ptr(float64(5)),
Ellipsize: langext.PTrue,
MultiCell: langext.PFalse,
minWidth: langext.Ptr(float64(5)),
ellipsize: langext.PTrue,
multiCell: langext.PFalse,
}
cellStyleMulti := TableCellStyleOpt{
cellStyleMulti := &TableCellStyleOpt{
PDFCellOpt: *NewPDFCellOpt().
FontSize(float64(8)).
BorderColorHex(uint32(0x666666)).
@@ -61,9 +63,9 @@ func TestPDFBuilder(t *testing.T) {
FillColorHex(uint32(0xC060C0)).
FillBackground(true).
TextColorHex(uint32(0x000000)),
MinWidth: langext.Ptr(float64(5)),
Ellipsize: langext.PFalse,
MultiCell: langext.PTrue,
minWidth: langext.Ptr(float64(5)),
ellipsize: langext.PFalse,
multiCell: langext.PTrue,
}
builder.Table().
@@ -74,7 +76,18 @@ func TestPDFBuilder(t *testing.T) {
AddRowDefaultStyle("test", "hello", "123", "end").
AddRowDefaultStyle("123", "helasdsalo", "a", "enwqad").
AddRowDefaultStyle("123asd", "TrimMeTrimMeTrimMeTrimMe", "a", "enwqad").
AddRowWithStyle(cellStyleMulti, "123", "helasdsalo", "a", "MultiCell: enwqad enw\nqad enwqad enwqad enwqad enwqad enwqad enwqad enwqad").
AddRowWithStyle(cellStyleMulti, "123", "helasdsalo", "a", "MultiCell: enwqad enw\nqad enwqad enwqad enwqad enwqad").
AddRowDefaultStyle("123", "helasdsalo", "a", "enwqad").
Debug(false).
Build()
builder.Table().
Widths("auto", "20", "1fr", "20").
PadX(2).
PadY(2).
BuildRow().RowStyle(cellStyleHeader).Cells("test", "hello", "123", "end").BuildRow().
BuildRow().Cells("test", "hello", "123", "end").BuildRow().
BuildRow().RowStyle(cellStyleMulti.FillHeight(true)).Cell("123").Cell("helasdsalo").Cell("a").Cell("MultiCell: enwqad enw\nqad enwqad enwqad enwqad enwqad").BuildRow().
AddRowDefaultStyle("123", "helasdsalo", "a", "enwqad").
Debug(false).
Build()
@@ -84,5 +97,7 @@ func TestPDFBuilder(t *testing.T) {
t.Fatal(err)
}
_ = os.WriteFile("wpdf_test.pdf", bin, 0644)
fn := "wpdf_test.pdf"
_ = os.WriteFile(fn, bin, 0644)
fmt.Println("file://" + path.Join(langext.Must(os.Getwd()), fn))
}