@@ -106,7 +106,7 @@ await Parallel.ForEachAsync(pdfTocs, async (item, _) =>
106106 var outputPath = Path . Combine ( outputFolder , outputName ) ;
107107
108108 await CreatePdf (
109- PrintPdf , PrintHeaderFooter , task , new ( baseUrl , url ) , toc , outputPath ,
109+ PrintPdf , PrintHeaderFooter , task , new ( baseUrl , url ) , toc , outputFolder , outputPath ,
110110 pageNumbers => pdfPageNumbers [ url ] = pageNumbers ) ;
111111
112112 task . Value = task . MaxValue ;
@@ -256,7 +256,7 @@ static string ExpandTemplate(string? pdfTemplate, int pageNumber, int totalPages
256256
257257 static async Task CreatePdf (
258258 Func < Outline , Uri , Task < byte [ ] ? > > printPdf , Func < Outline , int , int , Page , Task < byte [ ] > > printHeaderFooter , ProgressTask task ,
259- Uri outlineUrl , Outline outline , string outputPath , Action < Dictionary < Outline , int > > updatePageNumbers )
259+ Uri outlineUrl , Outline outline , string outputFolder , string outputPath , Action < Dictionary < Outline , int > > updatePageNumbers )
260260 {
261261 var tempDirectory = Path . Combine ( Path . GetTempPath ( ) , ".docfx" , "pdf" , "pages" ) ;
262262 Directory . CreateDirectory ( tempDirectory ) ;
@@ -357,7 +357,7 @@ async Task MergePdf()
357357 if ( ! pageBytes . TryGetValue ( node , out var bytes ) )
358358 continue ;
359359
360- var isCoverPage = url . AbsolutePath . TrimStart ( '/' ) . Equals ( outline . pdfCoverPage , GetStringComparison ( ) ) ;
360+ var isCoverPage = IsCoverPage ( url , outputFolder , outline . pdfCoverPage ) ;
361361
362362 var isTocPage = IsTocPage ( url ) ;
363363 if ( isTocPage )
@@ -440,6 +440,19 @@ PdfAction HandleUriAction(UriAction url)
440440
441441 static Uri CleanUrl ( Uri url ) => new UriBuilder ( url ) { Query = null , Fragment = null } . Uri ;
442442
443+ static bool IsCoverPage ( Uri pageUri , string baseFolder , string ? pdfCoverPage )
444+ {
445+ Debug . Assert ( Path . IsPathFullyQualified ( baseFolder ) ) ;
446+
447+ if ( string . IsNullOrEmpty ( pdfCoverPage ) )
448+ return false ;
449+
450+ string pagePath = pageUri . AbsolutePath . TrimStart ( '/' ) ;
451+ string covePagePath = PathUtility . MakeRelativePath ( baseFolder , Path . GetFullPath ( Path . Combine ( baseFolder , pdfCoverPage ) ) ) ;
452+
453+ return pagePath . Equals ( covePagePath , GetStringComparison ( ) ) ;
454+ }
455+
443456 static bool IsTocPage ( Uri url ) => url . AbsolutePath . StartsWith ( "/_pdftoc/" ) ;
444457
445458 Bookmarks CreateBookmarks ( Outline [ ] ? items )
0 commit comments