Added "OpenAfterCreating" app setting

This commit is contained in:
S T Chan 2018-10-08 22:20:15 -04:00
parent faf775a12c
commit 5f96177f74
5 changed files with 142 additions and 110 deletions

View File

@ -11,12 +11,12 @@
<system.diagnostics> <system.diagnostics>
<trace autoflush="true" /> <trace autoflush="true" />
<sources> <sources>
<source name="PdfScribe" <source name="PdfScribe"
switchName="PdfScribeAll" > switchName="PdfScribeAll" >
<listeners> <listeners>
<add name="textwriterListener" <add name="textwriterListener"
type="System.Diagnostics.TextWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener"
initializeData="PdfScribe_trace.log" initializeData="PdfScribe_trace.log"
traceOutputOptions="DateTime" /> 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 -->
@ -28,13 +28,16 @@
</switches> </switches>
</system.diagnostics> </system.diagnostics>
<applicationSettings> <applicationSettings>
<PdfScribe.Properties.Settings> <PdfScribe.Properties.Settings>
<setting name="OutputFile" serializeAs="String"> <setting name="OutputFile" serializeAs="String">
<value>%UserProfile%\PDFSCRIBE.PDF</value> <value>%UserProfile%\PDFSCRIBE.PDF</value>
</setting> </setting>
<setting name="AskUserForOutputFilename" serializeAs="String"> <setting name="AskUserForOutputFilename" serializeAs="String">
<value>True</value> <value>False</value>
</setting> </setting>
<setting name="OpenAfterCreating" serializeAs="String">
<value>False</value>
</setting>
</PdfScribe.Properties.Settings> </PdfScribe.Properties.Settings>
</applicationSettings> </applicationSettings>
</configuration> </configuration>

View File

@ -69,6 +69,7 @@ namespace PdfScribe
String.Format("-sOutputFile={0}", outputFilename), standardInputFilename }; String.Format("-sOutputFile={0}", outputFilename), standardInputFilename };
GhostScript64.CallAPI(ghostScriptArguments); GhostScript64.CallAPI(ghostScriptArguments);
DisplayPdf(outputFilename);
} }
} }
catch (IOException ioEx) catch (IOException ioEx)
@ -241,6 +242,22 @@ namespace PdfScribe
return pathIsValid; return pathIsValid;
} }
/// <summary>
/// Opens the PDF in the default viewer
/// if the OpenAfterCreating app setting is "True"
/// and the file extension is .PDF
/// </summary>
/// <param name="pdfFilename"></param>
static void DisplayPdf(String pdfFilename)
{
if (Properties.Settings.Default.OpenAfterCreating &&
!String.IsNullOrEmpty(Path.GetExtension(pdfFilename)) &&
(Path.GetExtension(pdfFilename).ToUpper() == ".PDF"))
{
Process.Start(pdfFilename);
}
}
/// <summary> /// <summary>
/// Displays up a topmost, OK-only message box for the error message /// Displays up a topmost, OK-only message box for the error message
/// </summary> /// </summary>

View File

@ -1,44 +1,53 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34003 // Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace PdfScribe.Properties { namespace PdfScribe.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.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())));
public static Settings Default { public static Settings Default {
get { get {
return defaultInstance; return defaultInstance;
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("%Temp%\\PDFSCRIBE.PDF")] [global::System.Configuration.DefaultSettingValueAttribute("%UserProfile%\\PDFSCRIBE.PDF")]
public string OutputFile { public string OutputFile {
get { get {
return ((string)(this["OutputFile"])); return ((string)(this["OutputFile"]));
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")] [global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool AskUserForOutputFilename { public bool AskUserForOutputFilename {
get { get {
return ((bool)(this["AskUserForOutputFilename"])); return ((bool)(this["AskUserForOutputFilename"]));
} }
} }
}
} [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool OpenAfterCreating {
get {
return ((bool)(this["OpenAfterCreating"]));
}
}
}
}

View File

@ -1,12 +1,15 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PdfScribe.Properties" GeneratedClassName="Settings"> <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PdfScribe.Properties" GeneratedClassName="Settings">
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="OutputFile" Type="System.String" Scope="Application"> <Setting Name="OutputFile" Type="System.String" Scope="Application">
<Value Profile="(Default)">%Temp%\PDFSCRIBE.PDF</Value> <Value Profile="(Default)">%UserProfile%\PDFSCRIBE.PDF</Value>
</Setting> </Setting>
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application"> <Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
</Settings> <Setting Name="OpenAfterCreating" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile> </SettingsFile>

View File

@ -1,44 +1,44 @@
# PdfScribe v1.0.5 # PdfScribe v1.0.6
PdfScribe is a PDF virtual printer. Check the [releases](https://github.com/stchan/PdfScribe/releases) page for this project to download a prebuilt MSI package. PdfScribe is a PDF virtual printer. Check the [releases](https://github.com/stchan/PdfScribe/releases) page for this project to download a prebuilt MSI package.
## System Requirements ## System Requirements
* 64-bit Windows Vista or later * 64-bit Windows Vista or later
* .NET Framework 4.0 or later * .NET Framework 4.0 or later
## Building from source ## Building from source
Visual Studio 2015, Wix 3.11, and Votive 2015 are required to build PdfScribe. Visual Studio 2017, Wix 3.11, and Votive 2017 are required to build PdfScribe.
PdfScribe links to, and distributes the following third party components: PdfScribe links to, and distributes the following third party components:
* Microsoft Postscript Printer Driver (V3) * Microsoft Postscript Printer Driver (V3)
* Ghostscript (64-bit) * Ghostscript (64-bit)
* Redmon 1.9 (64-bit) * Redmon 1.9 (64-bit)
## License ## License
Redmon is distributed under the GPL v3. Ghostscript is AGPL (more restrictive than GPLv3), so PdfScribe is bound by that license. Ghostscript is AGPL (more restrictive than GPLv3), so PdfScribe is bound by that license.
## Configuration ## Configuration
In the application config file (PdfScribe.exe.config), there are two settings in the "applicationSettings" element: In the application config file (PdfScribe.exe.config), there are two settings in the "applicationSettings" element:
* ****AskUserForOutputFilename**** - set value to *true* if you want PdfScribe to ask the user where to save the PDF. * ****AskUserForOutputFilename**** - set value to *true* if you want PdfScribe to ask the user where to save the PDF.
* ****OutputFile**** - if there is a constant filename you want the PDF to be saved to, set its value here. Environment variables can be used. PdfScribe will overwrite each time. This setting is ignored if **AskUserForOutputFilename** is set to *true*. * ****OutputFile**** - if there is a constant filename you want the PDF to be saved to, set its value here. Environment variables can be used. PdfScribe will overwrite each time. This setting is ignored if **AskUserForOutputFilename** is set to *true*.
* ****OpenAfterCreating**** - set value to *true* if you want the PDF automatically opened with the default viewer. This setting is ignored if the file extension is not .PDF
## To do ## To do
* Allow auto-generated filenames with sequence numbers if the user doesn't want to overwrite (ex: OUTPUT-001.PDF, OUTPUT-002.PDF, etc) * Allow auto-generated filenames with sequence numbers if the user doesn't want to overwrite (ex: OUTPUT-001.PDF, OUTPUT-002.PDF, etc)
* Allow file appending if **OutputFile** setting is used. * Allow file appending if **OutputFile** setting is used.
* GUI for configuration * GUI for configuration
* Allow selection of page sizes other than default * Allow selection of page sizes other than default
* Watermarking output * Watermarking output