get filepath form title by default
This commit is contained in:
parent
91c595cc6d
commit
faa9a059bc
@ -15,7 +15,8 @@
|
|||||||
<listeners>
|
<listeners>
|
||||||
<add name="textwriterListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="PdfScribe_trace.log" traceOutputOptions="DateTime"/>
|
<add name="textwriterListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="PdfScribe_trace.log" traceOutputOptions="DateTime"/>
|
||||||
<remove name="Default"/>
|
<remove name="Default"/>
|
||||||
<clear/> <!-- Remove the <clear /> element to turn on tracing output -->
|
<clear/>
|
||||||
|
<!-- Remove the <clear /> element to turn on tracing output -->
|
||||||
</listeners>
|
</listeners>
|
||||||
</source>
|
</source>
|
||||||
</sources>
|
</sources>
|
||||||
@ -31,9 +32,12 @@
|
|||||||
<setting name="OpenAfterCreating" serializeAs="String">
|
<setting name="OpenAfterCreating" serializeAs="String">
|
||||||
<value>False</value>
|
<value>False</value>
|
||||||
</setting>
|
</setting>
|
||||||
<setting name="AskUserForOutputFilename" serializeAs="String">
|
<setting name="UsePrintTitleAsOutputFileName" serializeAs="String">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="AskUserForOutputFilename" serializeAs="String">
|
||||||
|
<value>False</value>
|
||||||
|
</setting>
|
||||||
</PdfScribe.Properties.Settings>
|
</PdfScribe.Properties.Settings>
|
||||||
</applicationSettings>
|
</applicationSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -59,6 +59,7 @@ namespace PdfScribe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetPathFormTitle(ref outputFilename, standardInputFilename);
|
||||||
if (GetPdfOutputFilename(ref outputFilename))
|
if (GetPdfOutputFilename(ref outputFilename))
|
||||||
{
|
{
|
||||||
// Remove the existing PDF file if present
|
// Remove the existing PDF file if present
|
||||||
@ -170,6 +171,7 @@ namespace PdfScribe
|
|||||||
pdfFilenameDialog.ShowHelp = false;
|
pdfFilenameDialog.ShowHelp = false;
|
||||||
pdfFilenameDialog.Title = "PDF Scribe - Set output filename";
|
pdfFilenameDialog.Title = "PDF Scribe - Set output filename";
|
||||||
pdfFilenameDialog.ValidateNames = true;
|
pdfFilenameDialog.ValidateNames = true;
|
||||||
|
pdfFilenameDialog.FileName = outputFile;
|
||||||
if (pdfFilenameDialog.ShowDialog(dialogOwner) == DialogResult.OK)
|
if (pdfFilenameDialog.ShowDialog(dialogOwner) == DialogResult.OK)
|
||||||
{
|
{
|
||||||
outputFile = pdfFilenameDialog.FileName;
|
outputFile = pdfFilenameDialog.FileName;
|
||||||
@ -182,7 +184,7 @@ namespace PdfScribe
|
|||||||
default:
|
default:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
outputFile = GetOutputFilename();
|
outputFile = Properties.Settings.Default.UsePrintTitleAsOutputFileName && string.IsNullOrEmpty(outputFile) ? GetOutputFilename() : outputFile;
|
||||||
// Test if we can write to the destination
|
// Test if we can write to the destination
|
||||||
using (FileStream newOutputFile = File.Create(outputFile))
|
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()
|
private static String GetOutputFilename()
|
||||||
{
|
{
|
||||||
String outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Properties.Settings.Default.OutputFile));
|
String outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Properties.Settings.Default.OutputFile));
|
||||||
|
19
PdfScribe/Properties/Settings.Designer.cs
generated
19
PdfScribe/Properties/Settings.Designer.cs
generated
@ -1,10 +1,10 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// 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.
|
// 重新生成代码,这些更改将会丢失。
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ namespace PdfScribe.Properties {
|
|||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[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 {
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
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.Configuration.ApplicationScopedSettingAttribute()]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
[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 {
|
public bool AskUserForOutputFilename {
|
||||||
get {
|
get {
|
||||||
return ((bool)(this["AskUserForOutputFilename"]));
|
return ((bool)(this["AskUserForOutputFilename"]));
|
||||||
|
@ -8,8 +8,11 @@
|
|||||||
<Setting Name="OpenAfterCreating" Type="System.Boolean" Scope="Application">
|
<Setting Name="OpenAfterCreating" Type="System.Boolean" Scope="Application">
|
||||||
<Value Profile="(Default)">False</Value>
|
<Value Profile="(Default)">False</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
|
<Setting Name="UsePrintTitleAsOutputFileName" Type="System.Boolean" Scope="Application">
|
||||||
<Value Profile="(Default)">True</Value>
|
<Value Profile="(Default)">True</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
|
||||||
|
<Value Profile="(Default)">False</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
Loading…
Reference in New Issue
Block a user