Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Fix pdf generation when no bookmark #5

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions pkg/modules/chromium/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,16 +647,18 @@ func convertUrl(ctx *api.Context, chromium Api, engine gotenberg.PdfEngine, url
}

if options.GenerateDocumentOutline {
bookmarks, errMarshal := json.Marshal(options.Bookmarks)
outputBMPath := ctx.GeneratePath(".pdf")
if len(options.Bookmarks.Bookmarks) > 0 {
bookmarks, errMarshal := json.Marshal(options.Bookmarks)
outputBMPath := ctx.GeneratePath(".pdf")

if errMarshal == nil {
outputPath, err = pdfengines.ImportBookmarksStub(ctx, engine, outputPath, bookmarks, outputBMPath)
if err != nil {
return fmt.Errorf("import bookmarks into PDF err: %w", err)
if errMarshal == nil {
outputPath, err = pdfengines.ImportBookmarksStub(ctx, engine, outputPath, bookmarks, outputBMPath)
if err != nil {
return fmt.Errorf("import bookmarks into PDF err: %w", err)
}
} else {
return fmt.Errorf("import bookmarks into PDF errMarshal : %w", errMarshal)
}
} else {
return fmt.Errorf("import bookmarks into PDF errMarshal : %w", errMarshal)
}
}

Expand Down
Loading