Skip to content

Commit

Permalink
Use go embed and remove attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
apardods committed Dec 23, 2024
1 parent 3cee6a3 commit 7b01645
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
File renamed without changes.
12 changes: 5 additions & 7 deletions pkg/pdf/pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package pdf

import (
"context"
_ "embed"
"fmt"
"io/fs"
"os"
"path/filepath"
)

Expand Down Expand Up @@ -57,6 +57,9 @@ type XMPMetadata struct {
Filename string
}

//go:embed assets/zugferd.xmp
var zugferdXMPData []byte

// WithURL sets the URL to use for the connection to a remote server if needed.
func WithURL(url string) Config {
return func(in any) {
Expand Down Expand Up @@ -154,10 +157,5 @@ func prepareOptions(opts []Option) *options {
}

func loadXMP() []byte {
data, err := os.ReadFile("assets/zugferd.xmp")
if err != nil {
panic(err)
}
fmt.Println(string(data))
return data
return zugferdXMPData
}
10 changes: 5 additions & 5 deletions pkg/pdf/prince.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func (pc *princeConvertor) HTML(_ context.Context, data []byte, opts ...Option)
j.PDF = new(princepdf.PDF)
}
j.PDF.PDFXMP = xmpFilename
j.PDF.Attach = append(j.PDF.Attach, &princepdf.Attachment{
URL: xmpFilename,
Filename: xmpFilename,
Description: "XMP Metadata File",
})
// j.PDF.Attach = append(j.PDF.Attach, &princepdf.Attachment{
// URL: xmpFilename,
// Filename: xmpFilename,
// Description: "XMP Metadata File",
// })
}

return pc.client.Run(j)
Expand Down

0 comments on commit 7b01645

Please sign in to comment.