Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions docs/docs/pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions src/Docfx.App/PdfBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down