Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting the PdfDocument.Info.Producer property #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bld/
[Bb]in/
[Oo]bj/

# Visual Studo 2015 cache/options directory
# Visual Studio 2015 cache/options directory
.vs/

# MSTest test Results
Expand Down Expand Up @@ -90,7 +90,7 @@ _ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding addin-in
# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
Expand Down Expand Up @@ -129,7 +129,7 @@ publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
Expand Down
14 changes: 3 additions & 11 deletions src/PdfSharp/Pdf/PdfDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,9 @@ internal override void PrepareForSave()
if (info.Elements[PdfDocumentInformation.Keys.Creator] == null)
info.Creator = pdfSharpProducer;

// Keep original producer if file was imported.
string producer = info.Producer;
if (producer.Length == 0)
producer = pdfSharpProducer;
else
{
// Prevent endless concatenation if file is edited with PDFsharp more than once.
if (!producer.StartsWith(VersionInfo.Title))
producer = pdfSharpProducer + " (Original: " + producer + ")";
}
info.Elements.SetString(PdfDocumentInformation.Keys.Producer, producer);
// Set Producer if value is undefined
if (info.Elements[PdfDocumentInformation.Keys.Producer] == null)
info.Producer = VersionInfo.Producer;

// Prepare used fonts.
if (_fontTable != null)
Expand Down
3 changes: 2 additions & 1 deletion src/PdfSharp/Pdf/PdfDocumentInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ public string Creator
}

/// <summary>
/// Gets the producer application (for example, PDFsharp).
/// Gets or sets the name of the producer application (for example, PDFsharp).
/// </summary>
public string Producer
{
get { return Elements.GetString(Keys.Producer); }
set { Elements.SetString(Keys.Producer, value); }
}

/// <summary>
Expand Down