Skip to content

Commit

Permalink
Merge pull request #143 from MaceWindu/feature/outlines
Browse files Browse the repository at this point in the history
Add TaggedPDF and GenerateOutline to PageSettings
  • Loading branch information
Sicos1977 committed Mar 8, 2024
2 parents 4cb979e + c29c4c7 commit fc53c10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChromiumHtmlToPdfLib/Browser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,8 @@ internal async Task PrintToPdfAsync(Stream outputStream,
message.AddParameter("footerTemplate", pageSettings.FooterTemplate);
message.AddParameter("preferCSSPageSize", pageSettings.PreferCSSPageSize);
message.AddParameter("transferMode", "ReturnAsStream");
message.AddParameter("generateTaggedPDF", pageSettings.TaggedPDF);
message.AddParameter("generateDocumentOutline", pageSettings.GenerateOutline);

var result = countdownTimer == null
? await _pageConnection.SendForResponseAsync(message, cancellationToken).ConfigureAwait(false)
Expand Down
17 changes: 16 additions & 1 deletion ChromiumHtmlToPdfLib/Settings/PageSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ public class PageSettings : ICloneable
/// The paper format
/// </summary>
public PaperFormat PaperFormat { get; private set; }

/// <summary>
/// Generate tagged PDF. Defaults to true.
/// </summary>
public bool TaggedPDF { get; set; } = true;

/// <summary>
/// Generate outline bookmarks from header tags (H1-H6). Defaults to false.
/// Requires both <see cref="Converter.UseOldHeadlessMode"/> and <see cref="TaggedPDF"/> set to <c>true</c>.
/// </summary>
public bool GenerateOutline { get; set; }
#endregion

#region PageSettings
Expand Down Expand Up @@ -167,6 +178,8 @@ public void ResetToDefaultSettings()
MarginLeft = 0.4;
MarginRight = 0.4;
PageRanges = string.Empty;
TaggedPDF = true;
GenerateOutline = false;
}
#endregion

Expand Down Expand Up @@ -271,7 +284,9 @@ public object Clone()
MarginRight = MarginRight,
PageRanges = PageRanges,
IgnoreInvalidPageRanges = IgnoreInvalidPageRanges,
PreferCSSPageSize = PreferCSSPageSize
PreferCSSPageSize = PreferCSSPageSize,
TaggedPDF = TaggedPDF,
GenerateOutline = GenerateOutline
};
}
#endregion
Expand Down

0 comments on commit fc53c10

Please sign in to comment.