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

View File

@ -69,6 +69,7 @@ namespace PdfScribe
String.Format("-sOutputFile={0}", outputFilename), standardInputFilename };
GhostScript64.CallAPI(ghostScriptArguments);
DisplayPdf(outputFilename);
}
}
catch (IOException ioEx)
@ -241,6 +242,22 @@ namespace PdfScribe
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>
/// Displays up a topmost, OK-only message box for the error message
/// </summary>

View File

@ -1,44 +1,53 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34003
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PdfScribe.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("%Temp%\\PDFSCRIBE.PDF")]
public string OutputFile {
get {
return ((string)(this["OutputFile"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool AskUserForOutputFilename {
get {
return ((bool)(this["AskUserForOutputFilename"]));
}
}
}
}
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PdfScribe.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("%UserProfile%\\PDFSCRIBE.PDF")]
public string OutputFile {
get {
return ((string)(this["OutputFile"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool AskUserForOutputFilename {
get {
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'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PdfScribe.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="OutputFile" Type="System.String" Scope="Application">
<Value Profile="(Default)">%Temp%\PDFSCRIBE.PDF</Value>
</Setting>
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="PdfScribe.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="OutputFile" Type="System.String" Scope="Application">
<Value Profile="(Default)">%UserProfile%\PDFSCRIBE.PDF</Value>
</Setting>
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="OpenAfterCreating" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -1,44 +1,44 @@
# PdfScribe v1.0.5
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
* 64-bit Windows Vista or later
* .NET Framework 4.0 or later
## Building from source
Visual Studio 2015, Wix 3.11, and Votive 2015 are required to build PdfScribe.
PdfScribe links to, and distributes the following third party components:
* Microsoft Postscript Printer Driver (V3)
* Ghostscript (64-bit)
* Redmon 1.9 (64-bit)
## License
Redmon is distributed under the GPL v3. Ghostscript is AGPL (more restrictive than GPLv3), so PdfScribe is bound by that license.
## Configuration
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.
* ****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*.
## 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 file appending if **OutputFile** setting is used.
* GUI for configuration
* Allow selection of page sizes other than default
* Watermarking output
# 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.
## System Requirements
* 64-bit Windows Vista or later
* .NET Framework 4.0 or later
## Building from source
Visual Studio 2017, Wix 3.11, and Votive 2017 are required to build PdfScribe.
PdfScribe links to, and distributes the following third party components:
* Microsoft Postscript Printer Driver (V3)
* Ghostscript (64-bit)
* Redmon 1.9 (64-bit)
## License
Ghostscript is AGPL (more restrictive than GPLv3), so PdfScribe is bound by that license.
## Configuration
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.
* ****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
* 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.
* GUI for configuration
* Allow selection of page sizes other than default
* Watermarking output