mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 04:32:15 +01:00
feat(chromium): add GenerateDocumentOutline option
This commit is contained in:
committed by
Julien Neuhart
parent
62ba4877ac
commit
79f396f6ff
@@ -213,26 +213,31 @@ type PdfOptions struct {
|
|||||||
// PreferCssPageSize defines whether to prefer page size as defined by CSS.
|
// PreferCssPageSize defines whether to prefer page size as defined by CSS.
|
||||||
// If false, the content will be scaled to fit the paper size.
|
// If false, the content will be scaled to fit the paper size.
|
||||||
PreferCssPageSize bool
|
PreferCssPageSize bool
|
||||||
|
|
||||||
|
// GenerateDocumentOutline defines whether the document outline should be
|
||||||
|
// embedded into the PDF.
|
||||||
|
GenerateDocumentOutline bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultPdfOptions returns the default values for PdfOptions.
|
// DefaultPdfOptions returns the default values for PdfOptions.
|
||||||
func DefaultPdfOptions() PdfOptions {
|
func DefaultPdfOptions() PdfOptions {
|
||||||
return PdfOptions{
|
return PdfOptions{
|
||||||
Options: DefaultOptions(),
|
Options: DefaultOptions(),
|
||||||
Landscape: false,
|
Landscape: false,
|
||||||
PrintBackground: false,
|
PrintBackground: false,
|
||||||
Scale: 1.0,
|
Scale: 1.0,
|
||||||
SinglePage: false,
|
SinglePage: false,
|
||||||
PaperWidth: 8.5,
|
PaperWidth: 8.5,
|
||||||
PaperHeight: 11,
|
PaperHeight: 11,
|
||||||
MarginTop: 0.39,
|
MarginTop: 0.39,
|
||||||
MarginBottom: 0.39,
|
MarginBottom: 0.39,
|
||||||
MarginLeft: 0.39,
|
MarginLeft: 0.39,
|
||||||
MarginRight: 0.39,
|
MarginRight: 0.39,
|
||||||
PageRanges: "",
|
PageRanges: "",
|
||||||
HeaderTemplate: "<html><head></head><body></body></html>",
|
HeaderTemplate: "<html><head></head><body></body></html>",
|
||||||
FooterTemplate: "<html><head></head><body></body></html>",
|
FooterTemplate: "<html><head></head><body></body></html>",
|
||||||
PreferCssPageSize: false,
|
PreferCssPageSize: false,
|
||||||
|
GenerateDocumentOutline: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ func FormDataChromiumPdfOptions(ctx *api.Context) (*api.FormData, PdfOptions) {
|
|||||||
pageRanges string
|
pageRanges string
|
||||||
headerTemplate, footerTemplate string
|
headerTemplate, footerTemplate string
|
||||||
preferCssPageSize bool
|
preferCssPageSize bool
|
||||||
|
generateDocumentOutline bool
|
||||||
)
|
)
|
||||||
|
|
||||||
form.
|
form.
|
||||||
@@ -221,24 +222,26 @@ func FormDataChromiumPdfOptions(ctx *api.Context) (*api.FormData, PdfOptions) {
|
|||||||
String("nativePageRanges", &pageRanges, defaultPdfOptions.PageRanges).
|
String("nativePageRanges", &pageRanges, defaultPdfOptions.PageRanges).
|
||||||
Content("header.html", &headerTemplate, defaultPdfOptions.HeaderTemplate).
|
Content("header.html", &headerTemplate, defaultPdfOptions.HeaderTemplate).
|
||||||
Content("footer.html", &footerTemplate, defaultPdfOptions.FooterTemplate).
|
Content("footer.html", &footerTemplate, defaultPdfOptions.FooterTemplate).
|
||||||
Bool("preferCssPageSize", &preferCssPageSize, defaultPdfOptions.PreferCssPageSize)
|
Bool("preferCssPageSize", &preferCssPageSize, defaultPdfOptions.PreferCssPageSize).
|
||||||
|
Bool("generateDocumentOutline", &generateDocumentOutline, defaultPdfOptions.GenerateDocumentOutline)
|
||||||
|
|
||||||
pdfOptions := PdfOptions{
|
pdfOptions := PdfOptions{
|
||||||
Options: options,
|
Options: options,
|
||||||
Landscape: landscape,
|
Landscape: landscape,
|
||||||
PrintBackground: printBackground,
|
PrintBackground: printBackground,
|
||||||
Scale: scale,
|
Scale: scale,
|
||||||
SinglePage: singlePage,
|
SinglePage: singlePage,
|
||||||
PaperWidth: paperWidth,
|
PaperWidth: paperWidth,
|
||||||
PaperHeight: paperHeight,
|
PaperHeight: paperHeight,
|
||||||
MarginTop: marginTop,
|
MarginTop: marginTop,
|
||||||
MarginBottom: marginBottom,
|
MarginBottom: marginBottom,
|
||||||
MarginLeft: marginLeft,
|
MarginLeft: marginLeft,
|
||||||
MarginRight: marginRight,
|
MarginRight: marginRight,
|
||||||
PageRanges: pageRanges,
|
PageRanges: pageRanges,
|
||||||
HeaderTemplate: headerTemplate,
|
HeaderTemplate: headerTemplate,
|
||||||
FooterTemplate: footerTemplate,
|
FooterTemplate: footerTemplate,
|
||||||
PreferCssPageSize: preferCssPageSize,
|
PreferCssPageSize: preferCssPageSize,
|
||||||
|
GenerateDocumentOutline: generateDocumentOutline,
|
||||||
}
|
}
|
||||||
|
|
||||||
return form, pdfOptions
|
return form, pdfOptions
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ func printToPdfActionFunc(logger *zap.Logger, outputPath string, options PdfOpti
|
|||||||
WithMarginRight(options.MarginRight).
|
WithMarginRight(options.MarginRight).
|
||||||
WithPageRanges(pageRanges).
|
WithPageRanges(pageRanges).
|
||||||
WithPreferCSSPageSize(options.PreferCssPageSize).
|
WithPreferCSSPageSize(options.PreferCssPageSize).
|
||||||
|
WithGenerateDocumentOutline(options.GenerateDocumentOutline).
|
||||||
// Does not seem to work.
|
// Does not seem to work.
|
||||||
// See https://github.com/gotenberg/gotenberg/issues/831.
|
// See https://github.com/gotenberg/gotenberg/issues/831.
|
||||||
WithGenerateTaggedPDF(false)
|
WithGenerateTaggedPDF(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user