commit 42b7abe4f0713e247b986c0cfdd2416829aeec3e Author: S T Chan Date: Wed Dec 11 20:52:42 2013 -0500 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3bd9df7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +obj +bin +obj +bin +TestResult.xml +*.suo diff --git a/Lib/PS5UI.DLL b/Lib/PS5UI.DLL new file mode 100644 index 0000000..a62c801 Binary files /dev/null and b/Lib/PS5UI.DLL differ diff --git a/Lib/PSCRIPT.HLP b/Lib/PSCRIPT.HLP new file mode 100644 index 0000000..34ee8ba Binary files /dev/null and b/Lib/PSCRIPT.HLP differ diff --git a/Lib/PSCRIPT.NTF b/Lib/PSCRIPT.NTF new file mode 100644 index 0000000..b46cbf5 Binary files /dev/null and b/Lib/PSCRIPT.NTF differ diff --git a/Lib/PSCRIPT5.DLL b/Lib/PSCRIPT5.DLL new file mode 100644 index 0000000..334cf27 Binary files /dev/null and b/Lib/PSCRIPT5.DLL differ diff --git a/Lib/SCPDFPRN.ppd b/Lib/SCPDFPRN.ppd new file mode 100644 index 0000000..bac59ee --- /dev/null +++ b/Lib/SCPDFPRN.ppd @@ -0,0 +1,521 @@ +*PPD-Adobe: "4.3" +*FileVersion: "1.1" +*FormatVersion: "4.3" +*LanguageEncoding: ISOLatin1 +*LanguageVersion: English +*Manufacturer: "Ghostscript" +*ModelName: "Ghostscript PDF Writer" +*ShortNickName: "Ghostscript" +*NickName: "Ghostscript" +*% PCFileName should be of the form XXNNNNNN.PPD where XX is an assigned +*% manufacturer code. +*PCFileName: "SCPDFPRN.PPD" +*Product: "(PDF Scribe)" +*PSVersion: "(3010) 815" + +*% *DefaultImageableArea: +*% *DefaultPageRegion: +*% *PageRegion: +*% *ImageableArea: +*% *DefaultPageSize: +*% *PageSize: +*% *DefaultPaperDimension: +*% *PaperDimension: + +*% == Above are required + +*% This file was adapted from GHOSTPDF.PPD for PDF Scribe + +*Copyright: "2004-2006 Ghostgum Software Pty Ltd" +*% +*% Copyright (C) 2004-2006, Ghostgum Software Pty Ltd. All rights reserved. +*% +*% Permission is hereby granted, free of charge, to any person obtaining +*% a copy of this file ("Software"), to deal in the Software without +*% restriction, including without limitation the rights to use, copy, +*% modify, merge, publish, distribute, sublicense, and/or sell copies of +*% this Software, and to permit persons to whom this file is furnished to +*% do so, subject to the following conditions: +*% +*% This Software is distributed with NO WARRANTY OF ANY KIND. No author +*% or distributor accepts any responsibility for the consequences of using it, +*% or for whether it serves any particular purpose or works at all, unless he +*% or she says so in writing. +*% +*% The above copyright notice and this permission notice shall be included +*% in all copies or substantial portions of the Software. + +*% There is an accompanying file ghostpdf.inf that is used to +*% install this PPD on Windows 2k/XP. +*% This PPD includes configuration items specific to generating +*% PDF files with ghostscript. +*% If you are not using the ghostscript pdfwrite device, +*% all items in the PDF group should be left as "Default". + + +*% == Basic Capabilities +*LanguageLevel: "3" +*ColorDevice: True +*DefaultColorSpace: RGB +*FileSystem: True +*Extensions: CMYK FileSystem Composite +*TTRasterizer: Type42 +*FreeVM: "10000000" +*PrintPSErrors: True +*ContoneOnly: True +*% AccurateScreensSupport: True + +*% order dependency +*% 10 HWResolution +*% 20 PageSize and other page device parameters +*% 30 PDFSETTINGS +*% 40 distiller parameters + +*% == Resolution +*OpenUI *Resolution: PickOne +*DefaultResolution: 600dpi +*OrderDependency: 10 AnySetup *Resolution +*Resolution 72dpi: "<< /HWResolution [72 72] >> setpagedevice" +*Resolution 96dpi: "<< /HWResolution [96 96] >> setpagedevice" +*Resolution 144dpi: "<< /HWResolution [144 144] >> setpagedevice" +*Resolution 150dpi: "<< /HWResolution [150 150] >> setpagedevice" +*Resolution 300dpi: "<< /HWResolution [300 300] >> setpagedevice" +*Resolution 600dpi: "<< /HWResolution [600 600] >> setpagedevice" +*Resolution 720dpi: "<< /HWResolution [720 720] >> setpagedevice" +*Resolution 1200dpi: "<< /HWResolution [1200 1200] >> setpagedevice" +*Resolution 2400dpi: "<< /HWResolution [2400 2400] >> setpagedevice" +*Resolution 3600dpi: "<< /HWResolution [3600 3600] >> setpagedevice" +*Resolution 4000dpi: "<< /HWResolution [4000 4000] >> setpagedevice" +*CloseUI: *Resolution + + +*% == Paper stuff +*% Page sizes taken from ghostscript gs_statd.ps. +*% Ghostscript pdfwrite ignores Orientation, so set the +*% custom page width/height and then use an Install procedure +*% to rotate the image. + +*HWMargins: 0 0 0 0 +*ParamCustomPageSize Width: 1 points 1 5670 +*ParamCustomPageSize Height: 2 points 1 5670 +*ParamCustomPageSize WidthOffset/Width Margin: 3 points 0 5670 +*ParamCustomPageSize HeightOffset/Height Margin: 4 points 0 5670 +*ParamCustomPageSize Orientation: 5 int 0 3 +*NonUIOrderDependency: 20 AnySetup *CustomPageSize +*CustomPageSize True: " + 5 -2 roll exch 5 2 roll + 3 -2 roll exch 3 2 roll + [ {} + {90 rotate 0 currentpagedevice /PageSize get 0 get neg translate} + {180 rotate currentpagedevice /PageSize get + dup 0 get neg exch 1 get neg translate} + {270 rotate currentpagedevice /PageSize get 1 get neg 0 translate} + ] exch get + 4 dict dup begin 6 1 roll + /Install exch def + 2 array astore /PageOffset exch def + 2 array astore /PageSize exch def + /ImagingBBox null def + end setpagedevice" +*End +*MaxMediaWidth: "5670" +*MaxMediaHeight: "5670" + +*LandscapeOrientation: Any + +*OpenUI *PageSize: PickOne +*DefaultPageSize: Letter +*OrderDependency: 20 AnySetup *PageSize +*PageSize Tabloid: "<< /PageSize [792 1224] /ImagingBBox null >> setpagedevice" +*PageSize Ledger: "<< /PageSize [1224 792] /ImagingBBox null >> setpagedevice" +*PageSize Legal: "<< /PageSize [612 1008] /ImagingBBox null >> setpagedevice" +*PageSize Letter: "<< /PageSize [612 792] /ImagingBBox null >> setpagedevice" +*PageSize LetterSmall: "<< /PageSize [612 792] /ImagingBBox [25 25 587 767] >> setpagedevice" +*PageSize Statement: "<< /PageSize [396 612] /ImagingBBox null >> setpagedevice" +*PageSize Note: "<< /PageSize [612 792] /ImagingBBox [25 25 587 767] >> setpagedevice" +*PageSize A0: "<< /PageSize [2384 3370] /ImagingBBox null >> setpagedevice" +*PageSize A1: "<< /PageSize [1684 2384] /ImagingBBox null >> setpagedevice" +*PageSize A2: "<< /PageSize [1191 1684] /ImagingBBox null >> setpagedevice" +*PageSize A3: "<< /PageSize [842 1191] /ImagingBBox null >> setpagedevice" +*PageSize A4: "<< /PageSize [595 842] /ImagingBBox null >> setpagedevice" +*PageSize A4Small: "<< /PageSize [595 842] /ImagingBBox [25 25 570 817] >> setpagedevice" +*PageSize A5: "<< /PageSize [420 595] /ImagingBBox null >> setpagedevice" +*PageSize A6: "<< /PageSize [297 420] /ImagingBBox null >> setpagedevice" +*PageSize A7: "<< /PageSize [210 297] /ImagingBBox null >> setpagedevice" +*PageSize A8: "<< /PageSize [148 210] /ImagingBBox null >> setpagedevice" +*PageSize A9: "<< /PageSize [105 148] /ImagingBBox null >> setpagedevice" +*PageSize A10: "<< /PageSize [73 105] /ImagingBBox null >> setpagedevice" +*PageSize ISOB0/ISO B0: "<< /PageSize [2835 4008] /ImagingBBox null >> setpagedevice" +*PageSize ISOB1/ISO B1: "<< /PageSize [2004 2835] /ImagingBBox null >> setpagedevice" +*PageSize ISOB2/ISO B2: "<< /PageSize [1417 2004] /ImagingBBox null >> setpagedevice" +*PageSize ISOB3/ISO B3: "<< /PageSize [1001 1417] /ImagingBBox null >> setpagedevice" +*PageSize ISOB4/ISO B4: "<< /PageSize [709 1001] /ImagingBBox null >> setpagedevice" +*PageSize ISOB5/ISO B5: "<< /PageSize [499 709] /ImagingBBox null >> setpagedevice" +*PageSize ISOB6/ISO B6: "<< /PageSize [354 499] /ImagingBBox null >> setpagedevice" +*PageSize B0/JIS B0: "<< /PageSize [2920 4127] /ImagingBBox null >> setpagedevice" +*PageSize B1/JIS B1: "<< /PageSize [2064 2920] /ImagingBBox null >> setpagedevice" +*PageSize B2/JIS B2: "<< /PageSize [1460 2064] /ImagingBBox null >> setpagedevice" +*PageSize B3/JIS B3: "<< /PageSize [1032 1460] /ImagingBBox null >> setpagedevice" +*PageSize B4/JIS B4: "<< /PageSize [729 1032] /ImagingBBox null >> setpagedevice" +*PageSize B5/JIS B5: "<< /PageSize [516 729] /ImagingBBox null >> setpagedevice" +*PageSize B6/JIS B6: "<< /PageSize [363 516] /ImagingBBox null >> setpagedevice" +*PageSize EnvC0/Envelope C0: "<< /PageSize [2599 3677] /ImagingBBox null >> setpagedevice" +*PageSize EnvC1/Envelope C1: "<< /PageSize [1837 2599] /ImagingBBox null >> setpagedevice" +*PageSize EnvC2/Envelope C2: "<< /PageSize [1296 1837] /ImagingBBox null >> setpagedevice" +*PageSize EnvC3/Envelope C3: "<< /PageSize [918 1296] /ImagingBBox null >> setpagedevice" +*PageSize EnvC4/Envelope C4: "<< /PageSize [649 918] /ImagingBBox null >> setpagedevice" +*PageSize EnvC5/Envelope C5: "<< /PageSize [459 649] /ImagingBBox null >> setpagedevice" +*PageSize EnvC6/Envelope C6: "<< /PageSize [323 459] /ImagingBBox null >> setpagedevice" +*PageSize ARCHE: "<< /PageSize [2592 3456] /ImagingBBox null >> setpagedevice" +*PageSize ARCHD: "<< /PageSize [1728 2592] /ImagingBBox null >> setpagedevice" +*PageSize ARCHC: "<< /PageSize [1296 1728] /ImagingBBox null >> setpagedevice" +*PageSize ARCHB: "<< /PageSize [864 1296] /ImagingBBox null >> setpagedevice" +*PageSize ARCHA: "<< /PageSize [648 864] /ImagingBBox null >> setpagedevice" +*PageSize FLSA: "<< /PageSize [612 936] /ImagingBBox null >> setpagedevice" +*PageSize FLSE: "<< /PageSize [612 936] /ImagingBBox null >> setpagedevice" +*PageSize PA4: "<< /PageSize [595 792] /ImagingBBox null >> setpagedevice" +*CloseUI: *PageSize + +*OpenUI *PageRegion: PickOne +*DefaultPageRegion: Letter +*OrderDependency: 20 AnySetup *PageRegion +*PageRegion Tabloid: "<< /PageSize [792 1224] /ImagingBBox null >> setpagedevice" +*PageRegion Ledger: "<< /PageSize [1224 792] /ImagingBBox null >> setpagedevice" +*PageRegion Legal: "<< /PageSize [612 1008] /ImagingBBox null >> setpagedevice" +*PageRegion Letter: "<< /PageSize [612 792] /ImagingBBox null >> setpagedevice" +*PageRegion LetterSmall: "<< /PageSize [612 792] /ImagingBBox [25 25 587 767] >> setpagedevice" +*PageRegion Note: "<< /PageSize [612 792] /ImagingBBox [25 25 587 767] >> setpagedevice" +*PageRegion Statement: "<< /PageSize [396 612] /ImagingBBox null >> setpagedevice" +*PageRegion A0: "<< /PageSize [2384 3370] /ImagingBBox null >> setpagedevice" +*PageRegion A1: "<< /PageSize [1684 2384] /ImagingBBox null >> setpagedevice" +*PageRegion A2: "<< /PageSize [1191 1684] /ImagingBBox null >> setpagedevice" +*PageRegion A3: "<< /PageSize [842 1191] /ImagingBBox null >> setpagedevice" +*PageRegion A4: "<< /PageSize [595 842] /ImagingBBox null >> setpagedevice" +*PageRegion A4Small: "<< /PageSize [595 842] /ImagingBBox [25 25 570 817] >> setpagedevice" +*PageRegion A5: "<< /PageSize [420 595] /ImagingBBox null >> setpagedevice" +*PageRegion A6: "<< /PageSize [297 420] /ImagingBBox null >> setpagedevice" +*PageRegion A7: "<< /PageSize [210 297] /ImagingBBox null >> setpagedevice" +*PageRegion A8: "<< /PageSize [148 210] /ImagingBBox null >> setpagedevice" +*PageRegion A9: "<< /PageSize [105 148] /ImagingBBox null >> setpagedevice" +*PageRegion A10: "<< /PageSize [73 105] /ImagingBBox null >> setpagedevice" +*PageRegion ISOB0/ISO B0: "<< /PageSize [2835 4008] /ImagingBBox null >> setpagedevice" +*PageRegion ISOB1/ISO B1: "<< /PageSize [2004 2835] /ImagingBBox null >> setpagedevice" +*PageRegion ISOB2/ISO B2: "<< /PageSize [1417 2004] /ImagingBBox null >> setpagedevice" +*PageRegion ISOB3/ISO B3: "<< /PageSize [1001 1417] /ImagingBBox null >> setpagedevice" +*PageRegion ISOB4/ISO B4: "<< /PageSize [709 1001] /ImagingBBox null >> setpagedevice" +*PageRegion ISOB5/ISO B5: "<< /PageSize [499 709] /ImagingBBox null >> setpagedevice" +*PageRegion ISOB6/ISO B6: "<< /PageSize [354 499] /ImagingBBox null >> setpagedevice" +*PageRegion B0/JIS B0: "<< /PageSize [2920 4127] /ImagingBBox null >> setpagedevice" +*PageRegion B1/JIS B1: "<< /PageSize [2064 2920] /ImagingBBox null >> setpagedevice" +*PageRegion B2/JIS B2: "<< /PageSize [1460 2064] /ImagingBBox null >> setpagedevice" +*PageRegion B3/JIS B3: "<< /PageSize [1032 1460] /ImagingBBox null >> setpagedevice" +*PageRegion B4/JIS B4: "<< /PageSize [729 1032] /ImagingBBox null >> setpagedevice" +*PageRegion B5/JIS B5: "<< /PageSize [516 729] /ImagingBBox null >> setpagedevice" +*PageRegion B6/JIS B6: "<< /PageSize [363 516] /ImagingBBox null >> setpagedevice" +*PageRegion EnvC0/Envelope C0: "<< /PageSize [2599 3677] /ImagingBBox null >> setpagedevice" +*PageRegion EnvC1/Envelope C1: "<< /PageSize [1837 2599] /ImagingBBox null >> setpagedevice" +*PageRegion EnvC2/Envelope C2: "<< /PageSize [1296 1837] /ImagingBBox null >> setpagedevice" +*PageRegion EnvC3/Envelope C3: "<< /PageSize [918 1296] /ImagingBBox null >> setpagedevice" +*PageRegion EnvC4/Envelope C4: "<< /PageSize [649 918] /ImagingBBox null >> setpagedevice" +*PageRegion EnvC5/Envelope C5: "<< /PageSize [459 649] /ImagingBBox null >> setpagedevice" +*PageRegion EnvC6/Envelope C6: "<< /PageSize [323 459] /ImagingBBox null >> setpagedevice" +*PageRegion ARCHE: "<< /PageSize [2592 3456] /ImagingBBox null >> setpagedevice" +*PageRegion ARCHD: "<< /PageSize [1728 2592] /ImagingBBox null >> setpagedevice" +*PageRegion ARCHC: "<< /PageSize [1296 1728] /ImagingBBox null >> setpagedevice" +*PageRegion ARCHB: "<< /PageSize [864 1296] /ImagingBBox null >> setpagedevice" +*PageRegion ARCHA: "<< /PageSize [648 864] /ImagingBBox null >> setpagedevice" +*PageRegion FLSA: "<< /PageSize [612 936] /ImagingBBox null >> setpagedevice" +*PageRegion FLSE: "<< /PageSize [612 936] /ImagingBBox null >> setpagedevice" +*PageRegion PA4: "<< /PageSize [595 792] /ImagingBBox null >> setpagedevice" +*CloseUI: *PageRegion + +*DefaultImageableArea: Letter +*ImageableArea Tabloid: "0 0 792 1224" +*ImageableArea Ledger: "0 0 1224 792" +*ImageableArea Legal: "0 0 612 1008" +*ImageableArea Letter: "0 0 612 792" +*ImageableArea LetterSmall: "25 25 587 767" +*ImageableArea Note: "25 25 587 767" +*ImageableArea Statement: "0 0 396 612" +*ImageableArea A0: "0 0 2384 3370" +*ImageableArea A1: "0 0 1684 2384" +*ImageableArea A2: "0 0 1191 1684" +*ImageableArea A3: "0 0 842 1191" +*ImageableArea A4: "0 0 595 842" +*ImageableArea A4Small: "25 25 570 817" +*ImageableArea A5: "0 0 420 595" +*ImageableArea A6: "0 0 297 420" +*ImageableArea A7: "0 0 210 297" +*ImageableArea A8: "0 0 148 210" +*ImageableArea A9: "0 0 105 148" +*ImageableArea A10: "0 0 73 105" +*ImageableArea ISOB0/ISO B0: "0 0 2835 4008" +*ImageableArea ISOB1/ISO B1: "0 0 2004 2835" +*ImageableArea ISOB2/ISO B2: "0 0 1417 2004" +*ImageableArea ISOB3/ISO B3: "0 0 1001 1417" +*ImageableArea ISOB4/ISO B4: "0 0 709 1001" +*ImageableArea ISOB5/ISO B5: "0 0 499 709" +*ImageableArea ISOB6/ISO B6: "0 0 354 499" +*ImageableArea B0/JIS B0: "0 0 2920 4127" +*ImageableArea B1/JIS B1: "0 0 2064 2920" +*ImageableArea B2/JIS B2: "0 0 1460 2064" +*ImageableArea B3/JIS B3: "0 0 1032 1460" +*ImageableArea B4/JIS B4: "0 0 729 1032" +*ImageableArea B5/JIS B5: "0 0 516 729" +*ImageableArea B6/JIS B6: "0 0 363 516" +*ImageableArea EnvC0/Envelope C0: "0 0 2599 3677" +*ImageableArea EnvC1/Envelope C1: "0 0 1837 2599" +*ImageableArea EnvC2/Envelope C2: "0 0 1296 1837" +*ImageableArea EnvC3/Envelope C3: "0 0 918 1296" +*ImageableArea EnvC4/Envelope C4: "0 0 649 918" +*ImageableArea EnvC5/Envelope C5: "0 0 459 649" +*ImageableArea EnvC6/Envelope C6: "0 0 323 459" +*ImageableArea ARCHE: "0 0 2592 3456" +*ImageableArea ARCHD: "0 0 1728 2592" +*ImageableArea ARCHC: "0 0 1296 1728" +*ImageableArea ARCHB: "0 0 864 1296" +*ImageableArea ARCHA: "0 0 648 864" +*ImageableArea FLSA: "0 0 612 936" +*ImageableArea FLSE: "0 0 612 936" +*ImageableArea PA4: "0 0 595 792" + +*DefaultPaperDimension: Letter +*PaperDimension Tabloid: "792 1224" +*PaperDimension Ledger: "1224 792" +*PaperDimension Legal: "612 1008" +*PaperDimension Letter: "612 792" +*PaperDimension LetterSmall: "612 792" +*PaperDimension Note: "612 792" +*PaperDimension Statement: "396 612" +*PaperDimension A0: "2384 3370" +*PaperDimension A1: "1684 2384" +*PaperDimension A2: "1191 1684" +*PaperDimension A3: "842 1191" +*PaperDimension A4: "595 842" +*PaperDimension A4Small: "595 842" +*PaperDimension A5: "420 595" +*PaperDimension A6: "297 420" +*PaperDimension A7: "210 297" +*PaperDimension A8: "148 210" +*PaperDimension A9: "105 148" +*PaperDimension A10: "73 105" +*PaperDimension ISOB0/ISO B0: "2835 4008" +*PaperDimension ISOB1/ISO B1: "2004 2835" +*PaperDimension ISOB2/ISO B2: "1417 2004" +*PaperDimension ISOB3/ISO B3: "1001 1417" +*PaperDimension ISOB4/ISO B4: "709 1001" +*PaperDimension ISOB5/ISO B5: "499 709" +*PaperDimension ISOB6/ISO B6: "354 499" +*PaperDimension B0/JIS B0: "2920 4127" +*PaperDimension B1/JIS B1: "2064 2920" +*PaperDimension B2/JIS B2: "1460 2064" +*PaperDimension B3/JIS B3: "1032 1460" +*PaperDimension B4/JIS B4: "729 1032" +*PaperDimension B5/JIS B5: "516 729" +*PaperDimension B6/JIS B6: "363 516" +*PaperDimension EnvC0/Envelope C0: "2599 3677" +*PaperDimension EnvC1/Envelope C1: "1837 2599" +*PaperDimension EnvC2/Envelope C2: "1296 1837" +*PaperDimension EnvC3/Envelope C3: "918 1296" +*PaperDimension EnvC4/Envelope C4: "649 918" +*PaperDimension EnvC5/Envelope C5: "459 649" +*PaperDimension EnvC6/Envelope C6: "323 459" +*PaperDimension ARCHE: "2592 3456" +*PaperDimension ARCHD: "1728 2592" +*PaperDimension ARCHC: "1296 1728" +*PaperDimension ARCHB: "864 1296" +*PaperDimension ARCHA: "648 864" +*PaperDimension FLSA: "612 936" +*PaperDimension FLSE: "612 936" +*PaperDimension PA4: "595 792" + + +*% == Fonts +*DefaultFont: Courier +*% First the standard 35 aliases with the actual fonts commented out. +*Font Bookman-Demi: Standard "(1.05)" Standard ROM +*% *Font URWBookmanL-DemiBold: Standard "(1.05)" Standard ROM +*Font Bookman-DemiItalic: Standard "(1.05)" Standard ROM +*% *Font URWBookmanL-DemiBoldItal: Standard "(1.05)" Standard ROM +*Font Bookman-Light: Standard "(1.05)" Standard ROM +*% *Font URWBookmanL-Ligh: Standard "(1.05)" Standard ROM +*Font Bookman-LightItalic: Standard "(1.05)" Standard ROM +*% *Font URWBookmanL-LighItal: Standard "(1.05)" Standard ROM +*Font Courier: Standard "(1.05)" Standard ROM +*% *Font NimbusMonL-Regu: Standard "(1.05)" Standard ROM +*Font Courier-Oblique: Standard "(1.05)" Standard ROM +*% *Font NimbusMonL-ReguObli: Standard "(1.05)" Standard ROM +*Font Courier-Bold: Standard "(1.05)" Standard ROM +*% *Font NimbusMonL-Bold: Standard "(1.05)" Standard ROM +*Font Courier-BoldOblique: Standard "(1.05)" Standard ROM +*% *Font NimbusMonL-BoldObli: Standard "(1.05)" Standard ROM +*Font AvantGarde-Book: Standard "(1.05)" Standard ROM +*% *Font URWGothicL-Book: Standard "(1.05)" Standard ROM +*Font AvantGarde-BookOblique: Standard "(1.05)" Standard ROM +*% *Font URWGothicL-BookObli: Standard "(1.05)" Standard ROM +*Font AvantGarde-Demi: Standard "(1.05)" Standard ROM +*% *Font URWGothicL-Demi: Standard "(1.05)" Standard ROM +*Font AvantGarde-DemiOblique: Standard "(1.05)" Standard ROM +*% *Font URWGothicL-DemiObli: Standard "(1.05)" Standard ROM +*Font Helvetica: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-Regu: Standard "(1.05)" Standard ROM +*Font Helvetica-Oblique: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-ReguItal: Standard "(1.05)" Standard ROM +*Font Helvetica-Bold: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-Bold: Standard "(1.05)" Standard ROM +*Font Helvetica-BoldOblique: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-BoldItal: Standard "(1.05)" Standard ROM +*Font Helvetica-Narrow: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-ReguCond: Standard "(1.05)" Standard ROM +*Font Helvetica-Narrow-Oblique: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-ReguCondItal: Standard "(1.05)" Standard ROM +*Font Helvetica-Narrow-Bold: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-BoldCond: Standard "(1.05)" Standard ROM +*Font Helvetica-Narrow-BoldOblique: Standard "(1.05)" Standard ROM +*% *Font NimbusSanL-BoldCondItal: Standard "(1.05)" Standard ROM +*Font Palatino-Roman: Standard "(1.05)" Standard ROM +*% *Font URWPalladioL-Roma: Standard "(1.05)" Standard ROM +*Font Palatino-Italic: Standard "(1.05)" Standard ROM +*% *Font URWPalladioL-Ital: Standard "(1.05)" Standard ROM +*Font Palatino-Bold: Standard "(1.05)" Standard ROM +*% *Font URWPalladioL-Bold: Standard "(1.05)" Standard ROM +*Font Palatino-BoldItalic: Standard "(1.05)" Standard ROM +*% *Font URWPalladioL-BoldItal: Standard "(1.05)" Standard ROM +*Font NewCenturySchlbk-Roman: Standard "(1.05)" Standard ROM +*% *Font CenturySchL-Roma: Standard "(1.05)" Standard ROM +*Font NewCenturySchlbk-Italic: Standard "(1.05)" Standard ROM +*% *Font CenturySchL-Ital: Standard "(1.05)" Standard ROM +*Font NewCenturySchlbk-Bold: Standard "(1.05)" Standard ROM +*% *Font CenturySchL-Bold: Standard "(1.05)" Standard ROM +*Font NewCenturySchlbk-BoldItalic: Standard "(1.05)" Standard ROM +*% *Font CenturySchL-BoldItal: Standard "(1.05)" Standard ROM +*Font Times-Roman: Standard "(1.05)" Standard ROM +*% *Font NimbusRomNo9L-Regu: Standard "(1.05)" Standard ROM +*Font Times-Italic: Standard "(1.05)" Standard ROM +*% *Font NimbusRomNo9L-ReguItal: Standard "(1.05)" Standard ROM +*Font Times-Bold: Standard "(1.05)" Standard ROM +*% *Font NimbusRomNo9L-Medi: Standard "(1.05)" Standard ROM +*Font Times-BoldItalic: Standard "(1.05)" Standard ROM +*% *Font NimbusRomNo9L-MediItal: Standard "(1.05)" Standard ROM +*Font Symbol: Special "(001.005)" Special ROM +*% *Font StandardSymL: Special (001.005)" Special ROM +*Font ZapfChancery-MediumItalic: Standard "(1.05)" Standard ROM +*% *Font URWChanceryL-MediItal: Standard "(1.05)" Standard ROM +*Font ZapfDingbats: Special (001.005)" Special ROM +*% *Font Dingbats: Special (001.005)" Special ROM +*% Then a few ghostscript extras +*Font Charter-Roman: Standard "(2.0-1.0)" Standard ROM +*Font CharterBT-Roman: Standard "(2.0-1.0)" Standard ROM +*Font Charter-Italic: Standard "(2.0-1.0)" Standard ROM +*Font CharterBT-Italic: Standard "(2.0-1.0)" Standard ROM +*Font Charter-Bold: Standard "(2.0-1.0)" Standard ROM +*Font CharterBT-Bold: Standard "(2.0-1.0)" Standard ROM +*Font Charter-BoldItalic: Standard "(2.0-1.0)" Standard ROM +*Font CharterBT-BoldItalic: Standard "(2.0-1.0)" Standard ROM +*Font Utopia-Regular: Standard "(001.001)" Standard ROM +*Font Utopia-Italic: Standard "(001.001)" Standard ROM +*Font Utopia-Bold: Standard "(001.001)" Standard ROM +*Font Utopia-BoldItalic: Standard "(001.001)" Standard ROM + +*% == Most of these set distiller parameters +*% If the target device is not the Ghostscript pdfwrite device, +*% then these should all be left at "Default" +*OpenGroup: PDF + +*% == The pdfwrite device can select different color spaces +*OpenUI *ColorModel/PDF Colour Model: PickOne +*DefaultColorModel: Default +*OrderDependency: 20 AnySetup *ColorModel +*ColorModel Default: "" +*ColorModel Grey: "<< /ProcessColorModel /DeviceGray >> setpagedevice" +*ColorModel RGB: "<< /ProcessColorModel /DeviceRGB >> setpagedevice" +*ColorModel CMYK: "<< /ProcessColorModel /DeviceCMYK >> setpagedevice" +*CloseUI: *ColorModel + +*OpenUI *PDFSettings/PDF Settings: PickOne +*DefaultPDFSettings: Default +*OrderDependency: 30 AnySetup *PDFSettings +*PDFSettings Default: "" +*PDFSettings Screen: ".distillersettings /screen get setdistillerparams" +*PDFSettings Ebook: ".distillersettings /ebook get setdistillerparams" +*PDFSettings Printer: ".distillersettings /printer get setdistillerparams" +*PDFSettings Prepress: ".distillersettings /prepress get setdistillerparams" +*CloseUI: *PDFSettings + +*OpenUI *ColorImageFilter/PDF Colour Image Compression: PickOne +*DefaultColorImageFilter: Default +*OrderDependency: 40 AnySetup *ColorImageFilter +*ColorImageFilter Default: "" +*ColorImageFilter JPEG: "<< /AutoFilterColorImages false /ColorImageFilter /DCTEncode >> setdistillerparams" +*ColorImageFilter Flate: "<< /AutoFilterColorImages false /ColorImageFilter /FlateEncode >> setdistillerparams" +*CloseUI: *ColorImageFilter + +*OpenUI *GrayImageFilter/PDF Grey Image Compression: PickOne +*DefaultGrayImageFilter: Default +*OrderDependency: 40 AnySetup *GrayImageFilter +*GrayImageFilter Default: "" +*GrayImageFilter JPEG: "<< /AutoFilterGrayImages false /GrayImageFilter /DCTEncode >> setdistillerparams" +*GrayImageFilter Flate: "<< /AutoFilterGrayImages false /GrayImageFilter /FlateEncode >> setdistillerparams" +*CloseUI: *GrayImageFilter + +*OpenUI *MonoImageFilter/PDF Monochrome Image Compression: PickOne +*DefaultMonoImageFilter: Default +*OrderDependency: 40 AnySetup *MonoImageFilter +*MonoImageFilter Default: "" +*MonoImageFilter FaxG3/Fax G3: "<< /AutoFilterMonoImages false /MonoImageFilter /CCITTFaxEncode >> setdistillerparams" +*MonoImageFilter Flate: "<< /AutoFilterMonoImages false /MonoImageFilter /FlateEncode >> setdistillerparams" +*CloseUI: *MonoImageFilter + +*OpenUI *CompatibilityLevel/PDF Compatibility: PickOne +*DefaultCompatibilityLevel: Default +*OrderDependency: 40 AnySetup *CompatibilityLevel +*CompatibilityLevel Default: "" +*CompatibilityLevel 1.2: "<< /CompatibilityLevel 1.2 >> setdistillerparams" +*CompatibilityLevel 1.3: "<< /CompatibilityLevel 1.3 >> setdistillerparams" +*CompatibilityLevel 1.4: "<< /CompatibilityLevel 1.4 >> setdistillerparams" +*CloseUI: *CompatibilityLevel + +*OpenUI *AutoRotatePages/PDF AutoRotatePages: PickOne +*DefaultAutoRotatePages: Default +*OrderDependency: 40 AnySetup *AutoRotatePages +*AutoRotatePages Default: "" +*AutoRotatePages None: "<< /AutoRotatePages /None >> setdistillerparams" +*AutoRotatePages PageByPage: "<< /AutoRotatePages /PageByPage >> setdistillerparams" +*AutoRotatePages All: "<< /AutoRotatePages /All >> setdistillerparams" +*CloseUI: *AutoRotatePages + +*OpenUI *ParseDSCComments/PDF ParseDSCComments: PickOne +*DefaultParseDSCComments: Default +*OrderDependency: 40 AnySetup *ParseDSCComments +*ParseDSCComments Default: "" +*ParseDSCComments True: "<< /ParseDSCComments true >> setdistillerparams" +*ParseDSCComments False: "<< /ParseDSCComments false >> setdistillerparams" +*CloseUI: *ParseDSCComments + +*OpenUI *EmbedAllFonts/PDF EmbedAllFonts: PickOne +*DefaultEmbedAllFonts: Default +*OrderDependency: 40 AnySetup *EmbedAllFonts +*EmbedAllFonts Default: "" +*EmbedAllFonts True: "<< /EmbedAllFonts true >> setdistillerparams" +*EmbedAllFonts False: "<< /EmbedAllFonts false >> setdistillerparams" +*CloseUI: *EmbedAllFonts + +*OpenUI *SubsetFonts/PDF SubsetFonts: PickOne +*DefaultSubsetFonts: Default +*OrderDependency: 40 AnySetup *SubsetFonts +*SubsetFonts Default: "" +*SubsetFonts True: "<< /SubsetFonts true >> setdistillerparams" +*SubsetFonts False: "<< /SubsetFonts false >> setdistillerparams" +*CloseUI: *SubsetFonts + +*OpenUI *CompressPages/PDF Compress Pages: PickOne +*DefaultCompressPages: Default +*OrderDependency: 40 AnySetup *CompressPages +*CompressPages Default: "" +*CompressPages True: "<< /CompressPages true >> setdistillerparams" +*CompressPages False: "<< /CompressPages false >> setdistillerparams" +*CloseUI: *CompressPages + +*CloseGroup: PDF + +*% End of Ghostscript PDF Writer PPD file diff --git a/Lib/nunit-console-runner.dll b/Lib/nunit-console-runner.dll new file mode 100644 index 0000000..a2a21ce Binary files /dev/null and b/Lib/nunit-console-runner.dll differ diff --git a/Lib/nunit.core.dll b/Lib/nunit.core.dll new file mode 100644 index 0000000..b306fae Binary files /dev/null and b/Lib/nunit.core.dll differ diff --git a/Lib/nunit.core.interfaces.dll b/Lib/nunit.core.interfaces.dll new file mode 100644 index 0000000..4053b0d Binary files /dev/null and b/Lib/nunit.core.interfaces.dll differ diff --git a/Lib/nunit.framework.dll b/Lib/nunit.framework.dll new file mode 100644 index 0000000..780727f Binary files /dev/null and b/Lib/nunit.framework.dll differ diff --git a/Lib/nunit.util.dll b/Lib/nunit.util.dll new file mode 100644 index 0000000..122eff4 Binary files /dev/null and b/Lib/nunit.util.dll differ diff --git a/Lib/redmon64.dll b/Lib/redmon64.dll new file mode 100644 index 0000000..044e776 Binary files /dev/null and b/Lib/redmon64.dll differ diff --git a/PdfScribe.sln b/PdfScribe.sln new file mode 100644 index 0000000..006861b --- /dev/null +++ b/PdfScribe.sln @@ -0,0 +1,35 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C# Express 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfScribe", "PdfScribe\PdfScribe.csproj", "{1EAD8E9A-A123-4C37-B31E-AEE1354DF003}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfScribeUnitTests", "PdfScribeUnitTests\PdfScribeUnitTests.csproj", "{D387573C-D122-461C-B525-1545DBDB4FBA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.ActiveCfg = Debug|x64 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x64.Build.0 = Debug|x64 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x86.ActiveCfg = Debug|x86 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Debug|x86.Build.0 = Debug|x86 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x64.ActiveCfg = Release|x64 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x64.Build.0 = Release|x64 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x86.ActiveCfg = Release|x86 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003}.Release|x86.Build.0 = Release|x86 + {D387573C-D122-461C-B525-1545DBDB4FBA}.Debug|x64.ActiveCfg = Debug|x86 + {D387573C-D122-461C-B525-1545DBDB4FBA}.Debug|x64.Build.0 = Debug|x86 + {D387573C-D122-461C-B525-1545DBDB4FBA}.Debug|x86.ActiveCfg = Debug|x86 + {D387573C-D122-461C-B525-1545DBDB4FBA}.Debug|x86.Build.0 = Debug|x86 + {D387573C-D122-461C-B525-1545DBDB4FBA}.Release|x64.ActiveCfg = Release|x86 + {D387573C-D122-461C-B525-1545DBDB4FBA}.Release|x86.ActiveCfg = Release|x86 + {D387573C-D122-461C-B525-1545DBDB4FBA}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/PdfScribe/NativeMethods.cs b/PdfScribe/NativeMethods.cs new file mode 100644 index 0000000..852acef --- /dev/null +++ b/PdfScribe/NativeMethods.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; + +namespace PdfScribe +{ + + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct MONITOR_INFO_2 + { + [MarshalAs(UnmanagedType.LPTStr)] + public string pName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pEnvironment; + [MarshalAs(UnmanagedType.LPTStr)] + public string pDLLName; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct FILETIME + { + public UInt32 dwLowDateTime; + public UInt32 dwHighDateTime; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct DRIVER_INFO_6 + { + public UInt32 cVersion; + [MarshalAs(UnmanagedType.LPTStr)] + public string pName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pEnvironment; + [MarshalAs(UnmanagedType.LPTStr)] + public string pDriverPath; + [MarshalAs(UnmanagedType.LPTStr)] + public string pDataFile; + [MarshalAs(UnmanagedType.LPTStr)] + public string pConfigFile; + [MarshalAs(UnmanagedType.LPTStr)] + public string pHelpFile; + [MarshalAs(UnmanagedType.LPTStr)] + public string pDependentFiles; + [MarshalAs(UnmanagedType.LPTStr)] + public string pMonitorName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pDefaultDataType; + [MarshalAs(UnmanagedType.LPTStr)] + public string pszzPreviousNames; + public FILETIME ftDriverDate; + public UInt64 dwlDriverVersion; + [MarshalAs(UnmanagedType.LPTStr)] + public string pszMfgName; + [MarshalAs(UnmanagedType.LPTStr)] + public string pszOEMUrl; + [MarshalAs(UnmanagedType.LPTStr)] + public string pszHardwareID; + [MarshalAs(UnmanagedType.LPTStr)] + public string pszProvider; + + } + + [StructLayout(LayoutKind.Sequential)] + public class PRINTER_DEFAULTS + { + public string pDatatype; + public IntPtr pDevMode; + public int DesiredAccess; + } + + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] + public struct PRINTER_INFO_2 + { + public string pServerName; + public string pPrinterName; + public string pShareName; + public string pPortName; + public string pDriverName; + public string pComment; + public string pLocation; + public IntPtr pDevMode; + public string pSepFile; + public string pPrintProcessor; + public string pDatatype; + public string pParameters; + public IntPtr pSecurityDescriptor; + public uint Attributes; + public uint Priority; + public uint DefaultPriority; + public uint StartTime; + public uint UntilTime; + public uint Status; + public uint cJobs; + public uint AveragePPM; + } + + public static class NativeMethods + { + [DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)] + public static extern bool EnumMonitors(string pName, uint level, IntPtr pMonitors, uint cbBuf, ref uint pcbNeeded, ref uint pcReturned); + + [DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Auto)] + public static extern Int32 AddMonitor(String pName, UInt32 Level, ref MONITOR_INFO_2 pMonitors); + + [DllImport("winspool.drv", SetLastError = true, CharSet = CharSet.Auto)] + public static extern Int32 DeleteMonitor(String pName, String pEnvironment, String pMonitorName); + + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr); + + + [DllImport("winspool.drv", EntryPoint = "XcvDataW", SetLastError = true)] + public static extern bool XcvData(IntPtr hXcv, + [MarshalAs(UnmanagedType.LPWStr)] string pszDataName, + IntPtr pInputData, + uint cbInputData, + IntPtr pOutputData, + uint cbOutputData, + out uint pcbOutputNeeded, + out uint pwdStatus); + + + + [DllImport("winspool.drv", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)] + public static extern int AddPrinter(string pName, uint Level, [In] ref PRINTER_INFO_2 pPrinter); + + [DllImport("winspool.drv", EntryPoint = "OpenPrinterA", SetLastError = true)] + public static extern int OpenPrinter( + string pPrinterName, + ref IntPtr phPrinter, + PRINTER_DEFAULTS pDefault); + + [DllImport("winspool.drv", SetLastError = true)] + public static extern int ClosePrinter(IntPtr hPrinter); + + [DllImport("winspool.drv", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)] + public static extern bool DeletePrinter(IntPtr hPrinter); + + + [DllImport("winspool.drv", EntryPoint="AddPrinterDriver", CharSet = CharSet.Auto, SetLastError = true)] + public static extern bool AddPrinterDriver(String pName, + int Level, + ref DRIVER_INFO_6 pDriverInfo); + + [DllImport("winspool.drv")] + public static extern bool GetPrinterDriverDirectory(StringBuilder pName, + StringBuilder pEnv, + int Level, + [Out] StringBuilder outPath, + int bufferSize, + ref int Bytes); + + public static IntPtr DisableWow64Redirection() + { + IntPtr oldValue = IntPtr.Zero; + if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess) + if (!NativeMethods.Wow64DisableWow64FsRedirection(ref oldValue)) + throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not disable Wow64 file system redirection."); + return oldValue; + } + + [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] + public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr); + + public static void RevertWow64Redirection(IntPtr oldValue) + { + if (Environment.Is64BitOperatingSystem && !Environment.Is64BitProcess) + { + if (!NativeMethods.Wow64RevertWow64FsRedirection(oldValue)) + { + throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not reenable Wow64 file system redirection."); + } + } + } + + } +} diff --git a/PdfScribe/PdfScribe.csproj b/PdfScribe/PdfScribe.csproj new file mode 100644 index 0000000..b5cc212 --- /dev/null +++ b/PdfScribe/PdfScribe.csproj @@ -0,0 +1,111 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003} + Library + Properties + PdfScribe + PdfScribe + v4.0 + Client + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + true + true + false + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + true + true + false + + + + true + bin\Debug\ + DEBUG;TRACE + full + AnyCPU + prompt + true + true + false + + + bin\Release\ + TRACE + true + pdbonly + AnyCPU + prompt + true + true + + + + + + + + + + + + + + + + + + + + + + Designer + + + + + \ No newline at end of file diff --git a/PdfScribe/PdfScribeInstaller.cs b/PdfScribe/PdfScribeInstaller.cs new file mode 100644 index 0000000..c3693e2 --- /dev/null +++ b/PdfScribe/PdfScribeInstaller.cs @@ -0,0 +1,406 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Runtime.InteropServices; +using System.Linq; +using System.Text; + +namespace PdfScribe +{ + public class PdfScribeInstaller + { + + const string ENVIRONMENT_64 = "Windows x64"; + const string PRINTERNAME = "PDF Scribe"; + const string DRIVERNAME = "PDF Scribe Virtual Printer"; + const string HARDWAREID = "PDFScribe_Driver0101"; + const string PORTMONITOR = "PDFSCRIBE"; + const string MONITORDLL = "redmon64.dll"; + const string PORTNAME = "PSCRIBE:"; + const string PRINTPROCESOR = "winprint"; + + const string DRIVERMANUFACTURER = "S T Chan"; + + const string DRIVERFILE = "PSCRIPT5.DLL"; + const int DRIVERFILE_INDEX = 0; + const string DRIVERUIFILE = "PS5UI.DLL"; + const int DRIVERUIFILE_INDEX = 1; + const string DRIVERHELPFILE = "PSCRIPT.HLP"; + const int DRIVERHELPFILE_INDEX = 2; + const string DRIVERDATAFILE = "SCPDFPRN.PPD"; + const int DRIVERDATAFILE_INDEX = 3; + + + #region Port operations + private int AddPdfScribePort(string portName) + { + return DoXcvDataPortOperation(portName, "AddPort"); + } + + public void DeletePdfScribePort(string portName) + { + DoXcvDataPortOperation(portName, "DeletePort"); + } + + private int DoXcvDataPortOperation(string portName, string xcvDataOperation) + { + + int win32ErrorCode; + + PRINTER_DEFAULTS def = new PRINTER_DEFAULTS(); + + def.pDatatype = null; + def.pDevMode = IntPtr.Zero; + def.DesiredAccess = 1; //Server Access Administer + + IntPtr hPrinter = IntPtr.Zero; + + if (NativeMethods.OpenPrinter(",XcvMonitor " + PORTMONITOR, ref hPrinter, def) != 0) + { + if (!portName.EndsWith("\0")) + portName += "\0"; // Must be a null terminated string + + // Must get the size in bytes. Rememeber .NET strings are formed by 2-byte characters + uint size = (uint)(portName.Length * 2); + + // Alloc memory in HGlobal to set the portName + IntPtr portPtr = Marshal.AllocHGlobal((int)size); + Marshal.Copy(portName.ToCharArray(), 0, portPtr, portName.Length); + + uint needed; // Not that needed in fact... + uint xcvResult; // Will receive de result here + + NativeMethods.XcvData(hPrinter, xcvDataOperation, portPtr, size, IntPtr.Zero, 0, out needed, out xcvResult); + + NativeMethods.ClosePrinter(hPrinter); + Marshal.FreeHGlobal(portPtr); + win32ErrorCode = (int)xcvResult; + } + else + { + win32ErrorCode = Marshal.GetLastWin32Error(); + } + return win32ErrorCode; + + } + + #endregion + + #region Port Monitor + + public bool AddPdfScribePortMonitor(String monitorName, + String monitorFile, + String monitorPath) + { + bool monitorAdded = false; + + IntPtr oldRedirectValue = IntPtr.Zero; + + try + { + oldRedirectValue = NativeMethods.DisableWow64Redirection(); + if (!DoesMonitorExist(monitorName)) + { + // Copy the monitor DLL to + // the system directory + String fileSourcePath = Path.Combine(monitorPath, monitorFile); + String fileDestinationPath = Path.Combine(Environment.SystemDirectory, monitorFile); + File.Copy(fileSourcePath, fileDestinationPath, true); + MONITOR_INFO_2 newMonitor = new MONITOR_INFO_2(); + newMonitor.pName = monitorName; + newMonitor.pEnvironment = ENVIRONMENT_64; + newMonitor.pDLLName = monitorFile; + if (!AddPortMonitor(newMonitor)) + throw new Win32Exception(Marshal.GetLastWin32Error(), String.Format("Could not add port monitor {0}", monitorName)); + else + monitorAdded = true; + } + + } + finally + { + /* + // Remove the monitor dll if copied + try + { + File.Delete(Path.Combine(Environment.SystemDirectory, monitorFile)); + } + catch { } + */ + if (oldRedirectValue != IntPtr.Zero) NativeMethods.RevertWow64Redirection(oldRedirectValue); + } + + + return monitorAdded; + } + + public bool RemoveSoftscanPortMonitor(String monitorName) + { + bool monitorRemoved = false; + if ((NativeMethods.DeleteMonitor(null, ENVIRONMENT_64, monitorName)) != 0) + monitorRemoved = true; + return monitorRemoved; + } + + private bool AddPortMonitor(MONITOR_INFO_2 newMonitor) + { + bool monitorAdded = false; + if ((NativeMethods.AddMonitor(null, 2, ref newMonitor) != 0)) + { + monitorAdded = true; + } + return monitorAdded; + } + + private bool DeletePortMonitor(String monitorName) + { + bool monitorDeleted = false; + if ((NativeMethods.DeleteMonitor(null, ENVIRONMENT_64, monitorName)) != 0) + { + monitorDeleted = true; + } + return monitorDeleted; + } + + private bool DoesMonitorExist(String monitorName) + { + bool monitorExists = false; + List portMonitors = EnumerateMonitors(); + foreach (MONITOR_INFO_2 portMonitor in portMonitors) + { + if (portMonitor.pName == monitorName) + { + monitorExists = true; + break; + } + } + return monitorExists; + } + + public List EnumerateMonitors() + { + List portMonitors = new List(); + + uint pcbNeeded = 0; + uint pcReturned = 0; + + if (!NativeMethods.EnumMonitors(null, 2, IntPtr.Zero, 0, ref pcbNeeded, ref pcReturned)) + { + IntPtr pMonitors = Marshal.AllocHGlobal((int)pcbNeeded); + if (NativeMethods.EnumMonitors(null, 2, pMonitors, pcbNeeded, ref pcbNeeded, ref pcReturned)) + { + IntPtr currentMonitor = pMonitors; + + for (int i = 0; i < pcReturned; i++) + { + portMonitors.Add((MONITOR_INFO_2)Marshal.PtrToStructure(currentMonitor, typeof(MONITOR_INFO_2))); + currentMonitor = (IntPtr)(currentMonitor.ToInt32() + Marshal.SizeOf(typeof(MONITOR_INFO_2))); + } + Marshal.FreeHGlobal(pMonitors); + + } + else + { + // Failed to retrieve enumerate + throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not enumerate monitor ports."); + } + + } + else + { + throw new ApplicationException("Call to winspool.drv succeeded with a zero size buffer - unexpected error."); + } + + return portMonitors; + } + + #endregion + + #region Printer Install + + public String RetrievePrinterDriverDirectory() + { + StringBuilder driverDirectory = new StringBuilder(1024); + int dirSizeInBytes = 0; + if (!NativeMethods.GetPrinterDriverDirectory(null, + null, + 1, + driverDirectory, + 1024, + ref dirSizeInBytes)) + throw new ApplicationException("Could not retrieve printer driver directory."); + return driverDirectory.ToString(); + } + +#if DEBUG + public bool InstallSoftscanPrinter_Test() + { + String printerName = PRINTERNAME; + String driverSourceDirectory = @"C:\Code\OaisisRedmonInstaller\Lib\"; + String[] driverFilesToCopy = new String[] { DRIVERFILE, DRIVERDATAFILE, DRIVERHELPFILE, DRIVERUIFILE }; + String[] dependentFilesToCopy = new String[] { "PSCRIPT.NTF" }; + return InstallPdfScribePrinter(printerName, driverSourceDirectory, driverFilesToCopy, dependentFilesToCopy); + } +#endif + public bool InstallPdfScribePrinter(String printerName, + String driverSourceDirectory, + String[] driverFilesToCopy, + String[] dependentFilesToCopy) + { + bool printerInstalled = false; + + String driverDirectory = RetrievePrinterDriverDirectory(); + if (AddPdfScribePort(PORTNAME) == 0) + { + if (CopyPrinterDriverFiles(driverSourceDirectory, driverFilesToCopy.Concat(dependentFilesToCopy).ToArray())) + { + if (AddPdfScribePortMonitor(PORTMONITOR, MONITORDLL, driverSourceDirectory)) + { + if (InstallPrinterDriver(driverDirectory, dependentFilesToCopy)) + { + printerInstalled = AddPdfScribePrinter(); + } + } + } + } + return printerInstalled; + } + + private bool CopyPrinterDriverFiles(String driverSourceDirectory, + String[] filesToCopy) + { + bool filesCopied = false; + String driverDestinationDirectory = RetrievePrinterDriverDirectory(); + try + { + for (int loop = 0; loop < filesToCopy.Length; loop++) + { + String fileSourcePath = Path.Combine(driverSourceDirectory, filesToCopy[loop]); + String fileDestinationPath = Path.Combine(driverDestinationDirectory, filesToCopy[loop]); + try + { + File.Copy(fileSourcePath, fileDestinationPath); + } + catch (IOException) + { + // Just keep going - file was already + // there, but we didn't overwrite + continue; + } + } + filesCopied = true; + } + catch (UnauthorizedAccessException) + { } + catch (PathTooLongException) + { } + catch (DirectoryNotFoundException) + { } + catch (FileNotFoundException) + { } + catch (NotSupportedException) + { } + + + return filesCopied; + } + + private bool DeletePrinterDriverFiles(String driverSourceDirectory, + String[] filesToDelete) + { + bool allFilesDeleted = true; + for (int loop = 0; loop < filesToDelete.Length; loop++) + { + try + { + File.Delete(Path.Combine(driverSourceDirectory, filesToDelete[loop])); + } + catch + { + allFilesDeleted = false; + } + } + return allFilesDeleted; + } + + private bool InstallPrinterDriver(String driverSourceDirectory, + String[] dependentDriverFiles) + { + bool printerDriverInstalled = false; + DRIVER_INFO_6 printerDriverInfo = new DRIVER_INFO_6(); + + printerDriverInfo.cVersion = 3; + printerDriverInfo.pName = DRIVERNAME; + printerDriverInfo.pEnvironment = ENVIRONMENT_64; + printerDriverInfo.pDriverPath = Path.Combine(driverSourceDirectory, DRIVERFILE); + printerDriverInfo.pConfigFile = Path.Combine(driverSourceDirectory,DRIVERUIFILE); + printerDriverInfo.pHelpFile = Path.Combine(driverSourceDirectory,DRIVERHELPFILE); + printerDriverInfo.pDataFile = Path.Combine(driverSourceDirectory,DRIVERDATAFILE); + + StringBuilder nullTerminatedDependentFiles = new StringBuilder(); + if (dependentDriverFiles != null && + dependentDriverFiles.Length > 0) + { + for (int loop = 0; loop <= dependentDriverFiles.GetUpperBound(0); loop++) + { + nullTerminatedDependentFiles.Append(dependentDriverFiles[loop]); + nullTerminatedDependentFiles.Append("\0"); + } + nullTerminatedDependentFiles.Append("\0"); + } + else + { + nullTerminatedDependentFiles.Append("\0\0"); + } + printerDriverInfo.pDependentFiles = nullTerminatedDependentFiles.ToString(); + + printerDriverInfo.pMonitorName = PORTMONITOR; + printerDriverInfo.pDefaultDataType = String.Empty; + printerDriverInfo.dwlDriverVersion = 0x0000000200000000U; + printerDriverInfo.pszMfgName = DRIVERMANUFACTURER; + printerDriverInfo.pszHardwareID = HARDWAREID; + printerDriverInfo.pszProvider = DRIVERMANUFACTURER; + + printerDriverInstalled = NativeMethods.AddPrinterDriver(null, 6, ref printerDriverInfo); + if (printerDriverInstalled == false) + { + int lastWinError = Marshal.GetLastWin32Error(); + throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not add printer PDF Scribe printer driver."); + } + return printerDriverInstalled; + } + + + private bool AddPdfScribePrinter() + { + bool printerAdded = false; + PRINTER_INFO_2 pdfScribePrinter = new PRINTER_INFO_2(); + + pdfScribePrinter.pServerName = null; + pdfScribePrinter.pPrinterName = PRINTERNAME; + pdfScribePrinter.pPortName = PORTNAME; + pdfScribePrinter.pDriverName = DRIVERNAME; + pdfScribePrinter.pPrintProcessor = PRINTPROCESOR; + pdfScribePrinter.pDatatype = "RAW"; + pdfScribePrinter.Attributes = 0x00000002; + + int softScanPrinterHandle = NativeMethods.AddPrinter(null, 2, ref pdfScribePrinter); + if (softScanPrinterHandle != 0) + { + // Added ok + int closeCode = NativeMethods.ClosePrinter((IntPtr)softScanPrinterHandle); + printerAdded = true; + } + else + { + throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not add PDF Scribe virtual printer."); + } + return printerAdded; + } + + #endregion + + + } +} diff --git a/PdfScribe/Program.cs b/PdfScribe/Program.cs new file mode 100644 index 0000000..3225e12 --- /dev/null +++ b/PdfScribe/Program.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace PdfScribe +{ + class Program + { + static void Main(string[] args) + { + //RemovePort(); + //RemovePortMonitor(); + //TestGetPorts(); + //AddPort(); + //TestGetPrinterDriverDir(); + //TestInstallPrinterDriver(); + DeletePdfScribePort(); + } + + public static void AddPort() + { + var installer = new PdfScribeInstaller(); + installer.AddPdfScribePortMonitor("SOFTSCAN", + "redmon64.dll", + @"C:\Code\PdfScribe\Lib\"); + } + + public static void DeletePdfScribePort() + { + var installer = new PdfScribeInstaller(); + installer.DeletePdfScribePort("SSCAN"); + } + + public static void RemovePortMonitor() + { + var installer = new PdfScribeInstaller(); + installer.RemoveSoftscanPortMonitor("SOFTSCAN"); + installer.RemoveSoftscanPortMonitor("OAISISSOFTSCAN"); + } + + public static void TestGetPorts() + { + var installer = new PdfScribeInstaller(); + List monList = installer.EnumerateMonitors(); + foreach (MONITOR_INFO_2 currentMonitor in monList) + { + Console.WriteLine(currentMonitor.pName + " / " + + currentMonitor.pEnvironment + " / " + + currentMonitor.pDLLName); + } + } + + public static void TestGetPrinterDriverDir() + { + var installer = new PdfScribeInstaller(); + String driverDir = installer.RetrievePrinterDriverDirectory(); + } + + public static void TestInstallPrinterDriver() + { + var installer = new PdfScribeInstaller(); + /*installer.AddSoftscanPortMonitor("OAISISSOFTSCAN", + "redmon64.dll", + @"C:\Code\OaisisRedmonInstaller\Lib\"); */ + installer.InstallSoftscanPrinter_Test(); + //installer.RemoveSoftscanPortMonitor("SOFTSCAN"); + + } + } +} diff --git a/PdfScribe/Properties/AssemblyInfo.cs b/PdfScribe/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..65a6be4 --- /dev/null +++ b/PdfScribe/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PDF Scribe")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("S T Chan")] +[assembly: AssemblyProduct("PDF Scribe")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4bd5734a-468e-47bc-a038-112129182f70")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PdfScribe/app.manifest b/PdfScribe/app.manifest new file mode 100644 index 0000000..9e0556d --- /dev/null +++ b/PdfScribe/app.manifest @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PdfScribeUnitTests/App.config b/PdfScribeUnitTests/App.config new file mode 100644 index 0000000..b245d6f --- /dev/null +++ b/PdfScribeUnitTests/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PdfScribeUnitTests/NUnitConsoleRunner.cs b/PdfScribeUnitTests/NUnitConsoleRunner.cs new file mode 100644 index 0000000..8e539f3 --- /dev/null +++ b/PdfScribeUnitTests/NUnitConsoleRunner.cs @@ -0,0 +1,14 @@ +using System; + +namespace PdfScribeUnitTests +{ + // Written by blokeley + class NUnitConsoleRunner + { + [STAThread] + static void Main(string[] args) + { + NUnit.ConsoleRunner.Runner.Main(args); + } + } +} diff --git a/PdfScribeUnitTests/PdfScribeUnitTests.csproj b/PdfScribeUnitTests/PdfScribeUnitTests.csproj new file mode 100644 index 0000000..40a73e8 --- /dev/null +++ b/PdfScribeUnitTests/PdfScribeUnitTests.csproj @@ -0,0 +1,142 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {D387573C-D122-461C-B525-1545DBDB4FBA} + WinExe + Properties + PdfScribeUnitTests + PdfScribeUnitTests + v4.0 + Client + 512 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + PdfScribeUnitTests.NUnitConsoleRunner + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + true + false + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + true + true + + + + ..\Lib\nunit-console-runner.dll + + + ..\Lib\nunit.core.dll + + + ..\Lib\nunit.core.interfaces.dll + + + ..\Lib\nunit.framework.dll + + + ..\Lib\nunit.util.dll + + + + + + + + + + + + + + + + + {1EAD8E9A-A123-4C37-B31E-AEE1354DF003} + PdfScribe + + + + + + + + False + Microsoft .NET Framework 4 Client Profile %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file diff --git a/PdfScribeUnitTests/PdfScribeUnitTests.csproj.user b/PdfScribeUnitTests/PdfScribeUnitTests.csproj.user new file mode 100644 index 0000000..f8800ec --- /dev/null +++ b/PdfScribeUnitTests/PdfScribeUnitTests.csproj.user @@ -0,0 +1,33 @@ + + + + C:\Code\PdfScribe\PdfScribeUnitTests\ + PdfScribeUnitTests.csproj + + + C:\Code\PdfScribe\PdfScribeUnitTests\ + PdfScribeUnitTests.csproj + + + C:\Code\PdfScribe\PdfScribeUnitTests\ + PdfScribeUnitTests.csproj + + + C:\Code\PdfScribe\PdfScribeUnitTests\ + PdfScribeUnitTests.csproj + + + publish\ + + + + + + en-US + false + + + + + + \ No newline at end of file diff --git a/PdfScribeUnitTests/Properties/AssemblyInfo.cs b/PdfScribeUnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8bad39a --- /dev/null +++ b/PdfScribeUnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PdfScribeUnitTests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PdfScribeUnitTests")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("55b070cb-bccc-41b0-80b8-11cf2d169436")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PdfScribeUnitTests/UnitTests.cs b/PdfScribeUnitTests/UnitTests.cs new file mode 100644 index 0000000..a76d6d2 --- /dev/null +++ b/PdfScribeUnitTests/UnitTests.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using NUnit.Framework; + +using PdfScribe; + +namespace PdfScribeUnitTests +{ + [TestFixture] + public class UnitTests + { + #region Ctor + public UnitTests() + { } + #endregion + + [Test] + public void Test_DeletePdfScribePort() + { + var scribeInstaller = new PdfScribeInstaller(); + scribeInstaller.DeletePdfScribePort("SSCAN"); + } + + } +}