diff --git a/PdfScribe/App.config b/PdfScribe/App.config
index 3b5a589..3efb8df 100644
--- a/PdfScribe/App.config
+++ b/PdfScribe/App.config
@@ -1,39 +1,43 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- %UserProfile%\PDFSCRIBE.PDF
-
-
- False
-
-
- True
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %UserProfile%\PDFSCRIBE.PDF
+
+
+ False
+
+
+ True
+
+
+ False
+
+
+
diff --git a/PdfScribe/Program.cs b/PdfScribe/Program.cs
index 90b4ddb..9b060b8 100644
--- a/PdfScribe/Program.cs
+++ b/PdfScribe/Program.cs
@@ -59,6 +59,7 @@ namespace PdfScribe
}
}
+ GetPathFormTitle(ref outputFilename, standardInputFilename);
if (GetPdfOutputFilename(ref outputFilename))
{
// Remove the existing PDF file if present
@@ -170,6 +171,7 @@ namespace PdfScribe
pdfFilenameDialog.ShowHelp = false;
pdfFilenameDialog.Title = "PDF Scribe - Set output filename";
pdfFilenameDialog.ValidateNames = true;
+ pdfFilenameDialog.FileName = outputFile;
if (pdfFilenameDialog.ShowDialog(dialogOwner) == DialogResult.OK)
{
outputFile = pdfFilenameDialog.FileName;
@@ -182,7 +184,7 @@ namespace PdfScribe
default:
try
{
- outputFile = GetOutputFilename();
+ outputFile = Properties.Settings.Default.UsePrintTitleAsOutputFileName && string.IsNullOrEmpty(outputFile) ? GetOutputFilename() : outputFile;
// Test if we can write to the destination
using (FileStream newOutputFile = File.Create(outputFile))
{ }
@@ -227,6 +229,25 @@ namespace PdfScribe
}
+ private static void GetPathFormTitle(ref String outputFilename,
+ String standardInputFilename)
+ {
+ const String titlePrefix = "%%Title: ";
+ using (var fs = new FileStream(standardInputFilename, FileMode.Open, FileAccess.Read))
+ using (var sr = new StreamReader(fs))
+ {
+ string line = String.Empty;
+ while ((line = sr.ReadLine()) != null)
+ {
+ if (line.StartsWith(titlePrefix))
+ {
+ outputFilename = line.Substring(titlePrefix.Length);
+ break;
+ }
+ }
+ }
+ }
+
private static String GetOutputFilename()
{
String outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Properties.Settings.Default.OutputFile));
diff --git a/PdfScribe/Properties/Settings.Designer.cs b/PdfScribe/Properties/Settings.Designer.cs
index 2f98a67..ddc8890 100644
--- a/PdfScribe/Properties/Settings.Designer.cs
+++ b/PdfScribe/Properties/Settings.Designer.cs
@@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
+// 此代码由工具生成。
+// 运行时版本:4.0.30319.42000
//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
//
//------------------------------------------------------------------------------
@@ -12,7 +12,7 @@ namespace PdfScribe.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -44,6 +44,15 @@ namespace PdfScribe.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
+ public bool UsePrintTitleAsOutputFileName {
+ get {
+ return ((bool)(this["UsePrintTitleAsOutputFileName"]));
+ }
+ }
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool AskUserForOutputFilename {
get {
return ((bool)(this["AskUserForOutputFilename"]));
diff --git a/PdfScribe/Properties/Settings.settings b/PdfScribe/Properties/Settings.settings
index ff31d6c..a2a5846 100644
--- a/PdfScribe/Properties/Settings.settings
+++ b/PdfScribe/Properties/Settings.settings
@@ -8,8 +8,11 @@
False
-
+
True
+
+ False
+
\ No newline at end of file