@@ -106,7 +106,7 @@ await Parallel.ForEachAsync(pdfTocs, async (item, _) =>
106
106
var outputPath = Path . Combine ( outputFolder , outputName ) ;
107
107
108
108
await CreatePdf (
109
- PrintPdf , PrintHeaderFooter , task , new ( baseUrl , url ) , toc , outputPath ,
109
+ PrintPdf , PrintHeaderFooter , task , new ( baseUrl , url ) , toc , outputFolder , outputPath ,
110
110
pageNumbers => pdfPageNumbers [ url ] = pageNumbers ) ;
111
111
112
112
task . Value = task . MaxValue ;
@@ -256,7 +256,7 @@ static string ExpandTemplate(string? pdfTemplate, int pageNumber, int totalPages
256
256
257
257
static async Task CreatePdf (
258
258
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 )
260
260
{
261
261
var tempDirectory = Path . Combine ( Path . GetTempPath ( ) , ".docfx" , "pdf" , "pages" ) ;
262
262
Directory . CreateDirectory ( tempDirectory ) ;
@@ -357,7 +357,7 @@ async Task MergePdf()
357
357
if ( ! pageBytes . TryGetValue ( node , out var bytes ) )
358
358
continue ;
359
359
360
- var isCoverPage = url . AbsolutePath . TrimStart ( '/' ) . Equals ( outline . pdfCoverPage , GetStringComparison ( ) ) ;
360
+ var isCoverPage = IsCoverPage ( url , outputFolder , outline . pdfCoverPage ) ;
361
361
362
362
var isTocPage = IsTocPage ( url ) ;
363
363
if ( isTocPage )
@@ -440,6 +440,19 @@ PdfAction HandleUriAction(UriAction url)
440
440
441
441
static Uri CleanUrl ( Uri url ) => new UriBuilder ( url ) { Query = null , Fragment = null } . Uri ;
442
442
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
+
443
456
static bool IsTocPage ( Uri url ) => url . AbsolutePath . StartsWith ( "/_pdftoc/" ) ;
444
457
445
458
Bookmarks CreateBookmarks ( Outline [ ] ? items )
0 commit comments