Skip to content
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
3 changes: 3 additions & 0 deletions PdfScribe/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<!-- This will slow things down because another pass will be made through the postscript file - set it to "False" unless needed -->
<value>True</value>
</setting>
<setting name="DatetimeFormat" serializeAs="String">
<value>yyyy_MM_dd_HH_mm_ss</value>
</setting>
</PdfScribe.Properties.Settings>
</applicationSettings>
</configuration>
18 changes: 17 additions & 1 deletion PdfScribe/Program_2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,28 @@ ex is NotSupportedException ||

private static String GetOutputFilename()
{
String outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Properties.Settings.Default.OutputFile));
string rawFilename = Properties.Settings.Default.OutputFile;

if (rawFilename.Contains("%DATETIME%"))
{
string format = Properties.Settings.Default.DatetimeFormat;
if (string.IsNullOrWhiteSpace(format))
{
format = "yyyy_MM_dd_HH_mm_ss"; // Fallback
}

string datetimeString = DateTime.Now.ToString(format);
rawFilename = rawFilename.Replace("%DATETIME%", datetimeString);
}

string outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(rawFilename));

// Check if there are any % characters -
// even though it's a legal Windows filename character,
// it is a special character to Ghostscript
if (outputFilename.Contains("%"))
throw new ArgumentException("OutputFile setting contains % character.");

return outputFilename;
}

Expand Down
11 changes: 10 additions & 1 deletion PdfScribe/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions PdfScribe/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
<Setting Name="StripNoRedistill" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="DatetimeFormat" Type="System.String" Scope="Application">
<Value Profile="(Default)">yyyy_MM_dd_HH_mm_ss</Value>
</Setting>
</Settings>
</SettingsFile>