Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit f53f15a

Browse files
committed
Resolves #3 - Change PdfDocument.Info.Producer property from read-only to read/write
1 parent c23da69 commit f53f15a

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

PdfSharp/PdfSharp.Pdf/PdfDocument.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -365,22 +365,14 @@ internal override void PrepareForSave()
365365
{
366366
PdfDocumentInformation info = Info;
367367

368+
// Set Producer if value is undefined
369+
if (info.Elements[PdfDocumentInformation.Keys.Producer] == null)
370+
info.Producer = VersionInfo.Producer;
371+
368372
// Set Creator if value is undefined
369373
if (info.Elements[PdfDocumentInformation.Keys.Creator] == null)
370374
info.Creator = VersionInfo.Producer;
371375

372-
// Keep original producer if file was imported
373-
string producer = info.Producer;
374-
if (producer.Length == 0)
375-
producer = VersionInfo.Producer;
376-
else
377-
{
378-
// Prevent endless concatenation if file is edited with PDFsharp more than once
379-
if (!producer.StartsWith(VersionInfo.Title))
380-
producer = VersionInfo.Producer + " (Original: " + producer + ")";
381-
}
382-
info.Elements.SetString(PdfDocumentInformation.Keys.Producer, producer);
383-
384376
// Prepare used fonts
385377
if (this.fontTable != null)
386378
this.fontTable.PrepareForSave();

PdfSharp/PdfSharp.Pdf/PdfDocumentInformation.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ public string Creator
102102
}
103103

104104
/// <summary>
105-
/// Gets the producer application (for example, PDFsharp).
105+
/// Gets or sets the name of the producer application (for example, PDFsharp).
106106
/// </summary>
107107
public string Producer
108108
{
109109
get { return Elements.GetString(Keys.Producer); }
110+
set { Elements.SetString(Keys.Producer, value); }
110111
}
111112

112113
/// <summary>

0 commit comments

Comments
 (0)