feat(chromium): single page PDF

This commit is contained in:
Julien Neuhart
2024-02-23 21:17:28 +01:00
parent c47f5b06ba
commit bf5056f8fe
4 changed files with 65 additions and 4 deletions

View File

@@ -950,6 +950,41 @@ func TestChromiumBrowser_pdf(t *testing.T) {
"wait until 'window.globalVar === 'ready'' is true before print",
},
},
{
scenario: "single page",
browser: newChromiumBrowser(
browserArguments{
binPath: os.Getenv("CHROMIUM_BIN_PATH"),
wsUrlReadTimeout: 5 * time.Second,
allowList: regexp2.MustCompile("", 0),
denyList: regexp2.MustCompile("", 0),
},
),
fs: func() *gotenberg.FileSystem {
fs := gotenberg.NewFileSystem()
err := os.MkdirAll(fs.WorkingDirPath(), 0o755)
if err != nil {
t.Fatalf(fmt.Sprintf("expected no error but got: %v", err))
}
err = os.WriteFile(fmt.Sprintf("%s/index.html", fs.WorkingDirPath()), []byte("<h1>Custom header and footer</h1>"), 0o755)
if err != nil {
t.Fatalf("expected no error but got: %v", err)
}
return fs
}(),
options: PdfOptions{
SinglePage: true,
},
noDeadline: false,
start: true,
expectError: false,
expectedLogEntries: []string{
"single page PDF",
},
},
{
scenario: "custom header and footer",
browser: newChromiumBrowser(