From 5f96177f74ede83680a3ec927862eb5948ce1067 Mon Sep 17 00:00:00 2001 From: S T Chan Date: Mon, 8 Oct 2018 22:20:15 -0400 Subject: [PATCH] Added "OpenAfterCreating" app setting --- PdfScribe/App.config | 25 +++--- PdfScribe/Program.cs | 17 ++++ PdfScribe/Properties/Settings.Designer.cs | 97 +++++++++++++---------- PdfScribe/Properties/Settings.settings | 25 +++--- README.md | 88 ++++++++++---------- 5 files changed, 142 insertions(+), 110 deletions(-) diff --git a/PdfScribe/App.config b/PdfScribe/App.config index 5763d52..820e9ea 100644 --- a/PdfScribe/App.config +++ b/PdfScribe/App.config @@ -11,12 +11,12 @@ - - @@ -28,13 +28,16 @@ - - - %UserProfile%\PDFSCRIBE.PDF - - - True - + + + %UserProfile%\PDFSCRIBE.PDF + + + False + + + False + diff --git a/PdfScribe/Program.cs b/PdfScribe/Program.cs index a23b841..47a3aae 100644 --- a/PdfScribe/Program.cs +++ b/PdfScribe/Program.cs @@ -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; } + /// + /// Opens the PDF in the default viewer + /// if the OpenAfterCreating app setting is "True" + /// and the file extension is .PDF + /// + /// + static void DisplayPdf(String pdfFilename) + { + if (Properties.Settings.Default.OpenAfterCreating && + !String.IsNullOrEmpty(Path.GetExtension(pdfFilename)) && + (Path.GetExtension(pdfFilename).ToUpper() == ".PDF")) + { + Process.Start(pdfFilename); + } + } + /// /// Displays up a topmost, OK-only message box for the error message /// diff --git a/PdfScribe/Properties/Settings.Designer.cs b/PdfScribe/Properties/Settings.Designer.cs index 02812b2..77f2ad8 100644 --- a/PdfScribe/Properties/Settings.Designer.cs +++ b/PdfScribe/Properties/Settings.Designer.cs @@ -1,44 +1,53 @@ -//------------------------------------------------------------------------------ -// -// 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. -// -//------------------------------------------------------------------------------ - -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"])); - } - } - } -} +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +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"])); + } + } + } +} diff --git a/PdfScribe/Properties/Settings.settings b/PdfScribe/Properties/Settings.settings index 4d80443..26b34dd 100644 --- a/PdfScribe/Properties/Settings.settings +++ b/PdfScribe/Properties/Settings.settings @@ -1,12 +1,15 @@ - - - - - - %Temp%\PDFSCRIBE.PDF - - - False - - + + + + + + %UserProfile%\PDFSCRIBE.PDF + + + False + + + False + + \ No newline at end of file diff --git a/README.md b/README.md index 7f3a27f..7f02a29 100644 --- a/README.md +++ b/README.md @@ -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 + + + +