mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
* allow writing custom metadata to document builder #669 * skip null entries
This commit is contained in:
@@ -1092,6 +1092,11 @@ namespace UglyToad.PdfPig.Writer
|
||||
/// </summary>
|
||||
public class DocumentInformationBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Consumer applications can store custom metadata in the document information dictionary.
|
||||
/// </summary>
|
||||
public Dictionary<string, string> CustomMetadata { get; } = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="DocumentInformation.Title"/>.
|
||||
/// </summary>
|
||||
@@ -1136,6 +1141,16 @@ namespace UglyToad.PdfPig.Writer
|
||||
{
|
||||
var result = new Dictionary<NameToken, IToken>();
|
||||
|
||||
foreach (var pair in CustomMetadata)
|
||||
{
|
||||
if (pair.Key == null || pair.Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
result[NameToken.Create(pair.Key)] = new StringToken(pair.Value);
|
||||
}
|
||||
|
||||
if (Title != null)
|
||||
{
|
||||
result[NameToken.Title] = new StringToken(Title);
|
||||
|
||||
Reference in New Issue
Block a user