diff --git a/docs/docs/pdf.md b/docs/docs/pdf.md index 52934054753..f090967141e 100644 --- a/docs/docs/pdf.md +++ b/docs/docs/pdf.md @@ -109,6 +109,14 @@ HTML template for the print footer, or a path to an HTML page relative to the ro > For the cover page to appear in PDF, it needs to be included in build. > For instance, if `cover.md` is outputted to `_site/cover.html`, you should set `pdfCoverPage` to `cover.html`. +### `pdfHeaderFooterOnCover` + +Indicates whether to include the header and footer on the cover page. + +### `pdfHeaderFooterOnToc` + +Indicates whether to include the header and footer on the table of contents (toc) pages. + ## Customize PDF Pages PDF rendering uses the same HTML site template. To customize PDF page styles, use the [CSS print media](https://developer.mozilla.org/en-US/docs/Web/Guide/Printing): diff --git a/src/Docfx.App/PdfBuilder.cs b/src/Docfx.App/PdfBuilder.cs index 1357cd8236c..0fa18b9602b 100644 --- a/src/Docfx.App/PdfBuilder.cs +++ b/src/Docfx.App/PdfBuilder.cs @@ -51,6 +51,8 @@ class Outline public string? pdfHeaderTemplate { get; init; } public string? pdfFooterTemplate { get; init; } + public bool pdfHeaderFooterOnCover { get; init; } + public bool pdfHeaderFooterOnToc { get; init; } } public static Task Run(BuildJsonConfig config, string configDirectory, string? outputDirectory = null, CancellationToken cancellationToken = default) @@ -462,10 +464,10 @@ async Task MergePdf() CopyLinkFunc = x => CopyLink(node, x), }); - if (isCoverPage) + if (isCoverPage && !outline.pdfHeaderFooterOnCover) continue; - if (isTocPage) + if (isTocPage && !outline.pdfHeaderFooterOnToc) continue; var headerFooter = await printHeaderFooter(outline, pageNumber, numberOfPages, document.GetPage(i));