Skip to content

Commit 949ea81

Browse files
authored
Merge pull request #41 from synercoder/features/add-extra-info
Add extra info & update example
2 parents c2a2c06 + c372ee6 commit 949ea81

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

samples/Synercoding.FileFormats.Pdf.ConsoleTester/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static void Main(string[] args)
3030
{
3131
info.Author = "Gerard Gunnewijk";
3232
info.Title = "Example 1";
33+
info.ExtraInfo.Add("CutContourProgramId", "cloud-shape");
3334
})
3435
// Test placement using rectangle
3536
.AddPage(page =>

src/Synercoding.FileFormats.Pdf/DocumentInformation.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Synercoding.FileFormats.Pdf.LowLevel;
22
using Synercoding.FileFormats.Pdf.LowLevel.Extensions;
33
using System;
4+
using System.Collections.Generic;
45

56
namespace Synercoding.FileFormats.Pdf
67
{
@@ -59,6 +60,11 @@ internal DocumentInformation(PdfReference id)
5960
/// <inheritdoc />
6061
public PdfReference Reference { get; }
6162

63+
/// <summary>
64+
/// Extra information that will be added to the PDF meta data
65+
/// </summary>
66+
public IDictionary<string, string> ExtraInfo { get; } = new Dictionary<string, string>();
67+
6268
internal uint WriteToStream(PdfStream stream)
6369
{
6470
if (_isWritten)
@@ -84,6 +90,10 @@ internal uint WriteToStream(PdfStream stream)
8490
dictionary.Write(PdfName.Get("CreationDate"), _toPdfDate(did.CreationDate.Value));
8591
if (did.ModDate != null)
8692
dictionary.Write(PdfName.Get("ModDate"), _toPdfDate(did.ModDate.Value));
93+
94+
if(did.ExtraInfo.Count != 0)
95+
foreach(var kv in did.ExtraInfo)
96+
dictionary.Write(PdfName.Get(kv.Key), _toPdfHexadecimalString(kv.Value));
8797
});
8898

8999
_isWritten = true;

0 commit comments

Comments
 (0)