From 3d9aef53fb719158d15164cc279c1b592864595b Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:35:31 +0900 Subject: [PATCH] fix: skip header/footer rendering for cover page --- src/Docfx.App/PdfBuilder.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Docfx.App/PdfBuilder.cs b/src/Docfx.App/PdfBuilder.cs index 124d39b71d8..a1c4396f60f 100644 --- a/src/Docfx.App/PdfBuilder.cs +++ b/src/Docfx.App/PdfBuilder.cs @@ -357,6 +357,8 @@ async Task MergePdf() if (!pageBytes.TryGetValue(node, out var bytes)) continue; + var isCoverPage = url.AbsolutePath.TrimStart('/').Equals(outline.pdfCoverPage, GetStringComparison()); + var isTocPage = IsTocPage(url); if (isTocPage) { @@ -375,6 +377,9 @@ async Task MergePdf() var pageBuilder = builder.AddPage(document, i, x => CopyLink(node, x)); + if (isCoverPage) + continue; + if (isTocPage) continue; @@ -615,4 +620,12 @@ static string getMillimeter(double pt) return $"{Math.Round(pt * MillimeterPerInch / Dpi)}mm"; } } + + // Gets StringComparison instance for path string. + private static StringComparison GetStringComparison() + { + return PathUtility.IsPathCaseInsensitive() + ? StringComparison.OrdinalIgnoreCase + : StringComparison.Ordinal; + } }