diff --git a/LabelPrinter.spec b/LabelPrinter.spec index c59ddb2..b550edb 100644 --- a/LabelPrinter.spec +++ b/LabelPrinter.spec @@ -63,7 +63,7 @@ a = Analysis( 'print_label', 'print_label_pdf', 'svglib', 'cairosvg', 'watchdog', 'watchdog.observers', 'watchdog.events', - 'pystray', 'win32timezone', + 'pystray', 'win32api', 'win32print', 'win32timezone', ], hookspath=[], hooksconfig={}, diff --git a/build_exe.py b/build_exe.py index ebe7d1f..89a53c4 100644 --- a/build_exe.py +++ b/build_exe.py @@ -11,91 +11,41 @@ To build for Windows: 3. Run this script: python build_exe.py 4. The Windows .exe will be created in the dist/ folder -GhostScript bundling --------------------- -If GhostScript is installed on this build machine the script will -automatically copy the required files into conf\\ghostscript\\ before -calling PyInstaller so they are embedded in LabelPrinter.exe. -The target machine then needs NO separate GhostScript install. +Printing method +--------------- +SumatraPDF is bundled inside the exe and used for all printing. +It sends the PDF at its exact 35x25 mm page size via -print-settings noscale. +No GhostScript installation required on the build or target machine. """ import os import sys import subprocess -import shutil # Get the current directory script_dir = os.path.dirname(os.path.abspath(__file__)) -def prepare_ghostscript(): +def check_conf_folder(): """ - Find the system GhostScript installation and copy the minimum files - needed for bundling into conf\\ghostscript\\. - - Files copied: - conf\\ghostscript\\bin\\gswin64c.exe (or 32-bit variant) - conf\\ghostscript\\bin\\gsdll64.dll - conf\\ghostscript\\lib\\*.ps (PostScript init files) - - Returns True if GhostScript was found and prepared, False otherwise. + Verify that required files are present in the conf\ folder before building. + Returns True if all required files exist, False otherwise. """ - import glob - - gs_exe = None - gs_dll = None - gs_lib = None - - for pf in [r"C:\Program Files", r"C:\Program Files (x86)"]: - gs_base = os.path.join(pf, "gs") - if not os.path.isdir(gs_base): - continue - # Iterate versions newest-first - for ver_dir in sorted(os.listdir(gs_base), reverse=True): - bin_dir = os.path.join(gs_base, ver_dir, "bin") - lib_dir = os.path.join(gs_base, ver_dir, "lib") - if os.path.exists(os.path.join(bin_dir, "gswin64c.exe")): - gs_exe = os.path.join(bin_dir, "gswin64c.exe") - gs_dll = os.path.join(bin_dir, "gsdll64.dll") - gs_lib = lib_dir - break - if os.path.exists(os.path.join(bin_dir, "gswin32c.exe")): - gs_exe = os.path.join(bin_dir, "gswin32c.exe") - gs_dll = os.path.join(bin_dir, "gsdll32.dll") - gs_lib = lib_dir - break - if gs_exe: - break - - if not gs_exe: - print(" WARNING: GhostScript not found on this machine.") - print(" The exe will still build but GhostScript will NOT be bundled.") - print(" Install GhostScript from https://ghostscript.com/releases/gsdnld.html") - print(" then rebuild for sharp vector-quality printing.") - return False - - dest_bin = os.path.join("conf", "ghostscript", "bin") - dest_lib = os.path.join("conf", "ghostscript", "lib") - os.makedirs(dest_bin, exist_ok=True) - os.makedirs(dest_lib, exist_ok=True) - - print(f" GhostScript found: {os.path.dirname(gs_exe)}") - - shutil.copy2(gs_exe, dest_bin) - print(f" Copied: {os.path.basename(gs_exe)}") - - if os.path.exists(gs_dll): - shutil.copy2(gs_dll, dest_bin) - print(f" Copied: {os.path.basename(gs_dll)}") - - count = 0 - for ps_file in glob.glob(os.path.join(gs_lib, "*.ps")): - shutil.copy2(ps_file, dest_lib) - count += 1 - print(f" Copied {count} .ps init files from lib/") - - print(f" GhostScript prepared in conf\\ghostscript\\") - return True + required = [ + os.path.join('conf', 'SumatraPDF.exe'), + os.path.join('conf', 'SumatraPDF-settings.txt'), + os.path.join('conf', 'label_template_ok.svg'), + os.path.join('conf', 'label_template_nok.svg'), + os.path.join('conf', 'label_template.svg'), + ] + all_ok = True + for f in required: + if os.path.exists(f): + print(f" OK: {f}") + else: + print(f" MISSING: {f}") + all_ok = False + return all_ok if __name__ == '__main__': @@ -106,15 +56,14 @@ if __name__ == '__main__': # Change to script directory so relative paths work os.chdir(script_dir) - # Step 1: Prepare GhostScript for bundling (Windows only) - if sys.platform == "win32": - print("\n[1/2] Preparing GhostScript for bundling...") - prepare_ghostscript() - else: - print("\n[1/2] Skipping GhostScript prep (non-Windows build machine)") + # Step 1: Verify conf\ folder contents + print("\n[1/2] Checking conf\\ folder...") + if not check_conf_folder(): + print("\nERROR: One or more required conf\\ files are missing.") + print("Place SumatraPDF.exe and the SVG templates in the conf\\ folder, then retry.") + sys.exit(1) # Step 2: Build with PyInstaller using the handcrafted spec file. - # The spec's Python code auto-detects conf\\ghostscript\\ and includes it. print("\n[2/2] Building standalone executable via LabelPrinter.spec...") print("This may take a few minutes...\n") @@ -130,8 +79,7 @@ if __name__ == '__main__': print("=" * 60) print("\nExecutable location: ./dist/LabelPrinter.exe") print("\nBundled components:") - print(" - GhostScript (vector-quality printing)") - print(" - SumatraPDF (fallback printing)") + print(" - SumatraPDF (primary printing, noscale 35x25 mm)") print(" - SVG templates, conf files") print("\nYou can now:") print(" 1. Double-click LabelPrinter.exe to run") diff --git a/dist/LabelPrinter.exe b/dist/LabelPrinter.exe index 1c211b9..0a5b48b 100644 Binary files a/dist/LabelPrinter.exe and b/dist/LabelPrinter.exe differ diff --git a/dist/conf/SumatraPDF-settings.txt b/dist/conf/SumatraPDF-settings.txt deleted file mode 100644 index a8f6f8e..0000000 --- a/dist/conf/SumatraPDF-settings.txt +++ /dev/null @@ -1,94 +0,0 @@ -# For documentation, see https://www.sumatrapdfreader.org/settings/settings3-5-1.html -Theme = Light -FixedPageUI [ - TextColor = #000000 - BackgroundColor = #ffffff - SelectionColor = #f5fc0c - WindowMargin = 2 4 2 4 - PageSpacing = 4 4 - InvertColors = false - HideScrollbars = false -] -ComicBookUI [ - WindowMargin = 0 0 0 0 - PageSpacing = 4 4 - CbxMangaMode = false -] -ChmUI [ - UseFixedPageUI = false -] - -SelectionHandlers [ -] -ExternalViewers [ -] - -ZoomLevels = 8.33 12.5 18 25 33.33 50 66.67 75 100 125 150 200 300 400 600 800 1000 1200 1600 2000 2400 3200 4800 6400 -ZoomIncrement = 0 - -PrinterDefaults [ - PrintScale = noscale -] -ForwardSearch [ - HighlightOffset = 0 - HighlightWidth = 15 - HighlightColor = #6581ff - HighlightPermanent = false -] -Annotations [ - HighlightColor = #ffff00 - UnderlineColor = #00ff00 - SquigglyColor = #ff00ff - StrikeOutColor = #ff0000 - FreeTextColor = - FreeTextSize = 12 - FreeTextBorderWidth = 1 - TextIconColor = - TextIconType = - DefaultAuthor = -] - -RememberOpenedFiles = true -RememberStatePerDocument = true -RestoreSession = true -UiLanguage = en -EnableTeXEnhancements = false -DefaultDisplayMode = automatic -DefaultZoom = fit page -Shortcuts [ -] -EscToExit = false -ReuseInstance = false -ReloadModifiedDocuments = true - -MainWindowBackground = #80fff200 -FullPathInTitle = false -ShowMenubar = true -ShowToolbar = true -ShowFavorites = false -ShowToc = true -NoHomeTab = false -TocDy = 0 -SidebarDx = 0 -ToolbarSize = 18 -TabWidth = 300 -TreeFontSize = 0 -TreeFontWeightOffset = 0 -TreeFontName = automatic -SmoothScroll = false -ShowStartPage = false -CheckForUpdates = true -WindowState = 1 -WindowPos = 566 0 788 1020 -UseTabs = true -UseSysColors = false -CustomScreenDPI = 0 - -FileStates [ -] -SessionData [ -] -TimeOfLastUpdateCheck = 0 0 -OpenCountWeek = 790 - -# Settings below are not recognized by the current version diff --git a/dist/conf/SumatraPDF.exe b/dist/conf/SumatraPDF.exe deleted file mode 100644 index f034e5e..0000000 Binary files a/dist/conf/SumatraPDF.exe and /dev/null differ diff --git a/dist/conf/accepted.png b/dist/conf/accepted.png deleted file mode 100644 index d0d769d..0000000 Binary files a/dist/conf/accepted.png and /dev/null differ diff --git a/dist/conf/app.conf b/dist/conf/app.conf deleted file mode 100644 index a68db1d..0000000 --- a/dist/conf/app.conf +++ /dev/null @@ -1,4 +0,0 @@ -[Settings] -file_path = C:\temp\check.txt -printer = PDF - diff --git a/dist/conf/ghostscript/bin/gsdll64.dll b/dist/conf/ghostscript/bin/gsdll64.dll deleted file mode 100644 index 6990712..0000000 Binary files a/dist/conf/ghostscript/bin/gsdll64.dll and /dev/null differ diff --git a/dist/conf/ghostscript/bin/gswin64c.exe b/dist/conf/ghostscript/bin/gswin64c.exe deleted file mode 100644 index d9a546d..0000000 Binary files a/dist/conf/ghostscript/bin/gswin64c.exe and /dev/null differ diff --git a/dist/conf/ghostscript/lib/PDFA_def.ps b/dist/conf/ghostscript/lib/PDFA_def.ps deleted file mode 100644 index 96cb677..0000000 --- a/dist/conf/ghostscript/lib/PDFA_def.ps +++ /dev/null @@ -1,91 +0,0 @@ -%! -% This is a sample prefix file for creating a PDF/A document. -% Users should modify entries marked with "Customize". -% This assumes an ICC profile resides in the file (srgb.icc), -% in the current directory unless the user modifies the corresponding line below. - -% Define entries in the document Info dictionary : -[ /Title (Title) % Customise - /DOCINFO pdfmark - -% Define an ICC profile : -/ICCProfile (srgb.icc) % Customise -def - -[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark - -%% This code attempts to set the /N (number of components) key for the ICC colour space. -%% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if -%% ColorConversionStrategy is not set. -%% This is not 100% reliable. A better solution is for the user to edit this and replace -%% the code between the ---8<--- lines with a simple declaration like: -%% /N 3 -%% where the value of N is the number of components from the profile defined in /ICCProfile above. -%% -[{icc_PDFA} -<< -%% ----------8<--------------8<-------------8<--------------8<---------- - systemdict /ColorConversionStrategy known { - systemdict /ColorConversionStrategy get cvn dup /Gray eq { - pop /N 1 false - }{ - dup /RGB eq { - pop /N 3 false - }{ - /CMYK eq { - /N 4 false - }{ - (\tColorConversionStrategy not a device space, falling back to ProcessColorModel, output may not be valid PDF/A.\n)= - true - } ifelse - } ifelse - } ifelse - } { - (\tColorConversionStrategy not set, falling back to ProcessColorModel, output may not be valid PDF/A.\n)= - true - } ifelse - - { - currentpagedevice /ProcessColorModel get - dup /DeviceGray eq { - pop /N 1 - }{ - dup /DeviceRGB eq { - pop /N 3 - }{ - dup /DeviceCMYK eq { - pop /N 4 - } { - (\tProcessColorModel not a device space.)= - /ProcessColorModel cvx /rangecheck signalerror - } ifelse - } ifelse - } ifelse - } if -%% ----------8<--------------8<-------------8<--------------8<---------- - ->> /PUT pdfmark -[ -{icc_PDFA} -{ICCProfile (r) file} stopped -{ - (\n\tFailed to open the supplied ICCProfile for reading. This may be due to\n) print - (\t an incorrect filename or a failure to add --permit-file-read=\n) print - (\t to the command line. This PostScript program needs to open the file\n) print - (\t and you must explicitly grant it permission to do so.\n\n) print - (\tPDF/A processing aborted, output may not be a PDF/A file.\n\n) print - cleartomark -} -{ - /PUT pdfmark - % Define the output intent dictionary : - - [/_objdef {OutputIntent_PDFA} /type /dict /OBJ pdfmark - [{OutputIntent_PDFA} << - /Type /OutputIntent % Must be so (the standard requires). - /S /GTS_PDFA1 % Must be so (the standard requires). - /DestOutputProfile {icc_PDFA} % Must be so (see above). - /OutputConditionIdentifier (sRGB) % Customize - >> /PUT pdfmark - [{Catalog} <> /PUT pdfmark -} ifelse diff --git a/dist/conf/ghostscript/lib/PDFX_def.ps b/dist/conf/ghostscript/lib/PDFX_def.ps deleted file mode 100644 index 77010b1..0000000 --- a/dist/conf/ghostscript/lib/PDFX_def.ps +++ /dev/null @@ -1,126 +0,0 @@ -%! -% This is a sample prefix file for creating a PDF/X-3 document. -% Users should modify entries marked with "Customize". -% This assumes an ICC profile resides in the file (ISO Coated sb.icc) -% in the current directory unless the user modifies the corresponding line below. - -% First up, attempt to ensure the user has set ColorConversionStrategy correctly. -% PDF/X-3 only permits Gray or CMYK in the output. -% -systemdict /ColorConversionStrategy known { - systemdict /ColorConversionStrategy get cvn dup /Gray ne exch /CMYK ne and -} { - (\nERROR: ColorConversionStrategy not set.)= - true -} ifelse -{ (ERROR: ColorConversionStrategy must be /DeviceGray or /DeviceCMYK.)= - /ColorConversionStrategy cvx /rangecheck signalerror -} if - - -% Define entries in the document Info dictionary : -% -systemdict /PDFX known {systemdict /PDFX get}{3} ifelse - -dup 1 eq { - [ /GTS_PDFXVersion (PDF/X-1a:2001) % Must be so (the standard requires). - /Title (Title) % Customize. - /Trapped /False % Must be so (Ghostscript doesn't provide other). - /DOCINFO pdfmark -} if -dup 3 eq { - [ /GTS_PDFXVersion (PDF/X-3:2002) % Must be so (the standard requires). - /Title (Title) % Customize. - /Trapped /False % Must be so (Ghostscript doesn't provide other). - /DOCINFO pdfmark -} if -4 eq { - [ /GTS_PDFXVersion (PDF/X-4) % Must be so (the standard requires). - /Title (Title) % Customize. - /Trapped /False % Must be so (Ghostscript doesn't provide other). - /DOCINFO pdfmark -} if - - -/ICCProfile (ISO Coated sb.icc) def % Customize or remove. - -% Define an ICC profile in the output, if the user specified one. -% -currentdict /ICCProfile known { - [/_objdef {icc_PDFX} /type /stream /OBJ pdfmark - -% This code attempts to set the /N (number of components) key for the ICC colour space. -% To do this it checks the ColorConversionStrategy or the device ProcessColorModel if -% ColorConversionStrategy is not set. -% This is not 100% reliable. A better solution is for the user to edit this and replace -% the code between the ---8<--- lines with a simple declaration like: -% /N 3 -% where the value of N is the number of components from the profile defined in /ICCProfile above. -% Note, if you don't set ColorConversionStrategy, the output will likely be invalid anyway. - [{icc_PDFX} << -% ----------8<--------------8<-------------8<--------------8<---------- - systemdict /ColorConversionStrategy known { - systemdict /ColorConversionStrategy get cvn dup /Gray eq { - pop /N 1 false - }{ - dup /RGB eq { - systemdict /PDFX known {systemdict /PDFX get}{3} ifelse - 4 lt { - (RGB is not a valid ColorConversionStrategy for PDF/X output)= - /ColorConversionStrategycvx /rangecheck signalerror - } if - }{ - /CMYK eq { - /N 4 false - }{ - (ColorConversionStrategy not a device space, falling back to ProcessColorModel, output may not be valid PDF/X.)= - true - } ifelse - } ifelse - } ifelse - } { - (ColorConversionStrategy not set, falling back to ProcessColorModel, output may not be valid PDF/X.)= - true - } ifelse - - { - currentpagedevice /ProcessColorModel get - dup /DeviceGray eq { - pop /N 1 - }{ - dup /DeviceRGB eq { - systemdict /PDFX known {systemdict /PDFX get}{3} ifelse - 4 lt { - (RGB is not a valid ProcessColorModel for PDF/X output)= - /ColorConversionStrategycvx /rangecheck signalerror - } if - }{ - dup /DeviceCMYK eq { - pop /N 4 - } { - (ProcessColorModel not a device space.)= - /ProcessColorModel cvx /rangecheck signalerror - } ifelse - } ifelse - } ifelse - } if -% ----------8<--------------8<-------------8<--------------8<---------- - >> /PUT pdfmark - [{icc_PDFX} ICCProfile (r) file /PUT pdfmark -} if - -% Define the output intent dictionary : - -[/_objdef {OutputIntent_PDFX} /type /dict /OBJ pdfmark -[{OutputIntent_PDFX} << - /Type /OutputIntent % Must be so (the standard requires). - /S /GTS_PDFX % Must be so (the standard requires). - /OutputCondition (Commercial and specialty printing) % Customize - /Info (none) % Customize - /OutputConditionIdentifier (CGATS TR001) % Customize - /RegistryName (http://www.color.org) % Must be so (the standard requires). - currentdict /ICCProfile known { - /DestOutputProfile {icc_PDFX} % Must be so (see above). - } if ->> /PUT pdfmark -[{Catalog} <> /PUT pdfmark diff --git a/dist/conf/ghostscript/lib/acctest.ps b/dist/conf/ghostscript/lib/acctest.ps deleted file mode 100644 index 2af46be..0000000 --- a/dist/conf/ghostscript/lib/acctest.ps +++ /dev/null @@ -1,99 +0,0 @@ -%! -% Check that operators do their access tests correctly. - -% proc dotest => . -/dotest - { - dup - mark - exch - stopped not % False if error, true if no error. - { (Allowed access: ) print cleartomark == } - if - clear - } -def - -0 0 moveto % So the show commands don't bomb because of nocurrentpoint. - -{ [1 2] executeonly aload } dotest -{ (string) executeonly (seek) anchorsearch } dotest -{ (string) (seek) executeonly anchorsearch } dotest -{ 100 101 (string) noaccess ashow} dotest -{ 100 1 array readonly astore } dotest -{ 100 101 102 103 104 (string) noaccess awidthshow } dotest -{ 1 dict noacess begin } dotest -{ 1 array executeonly 1 array copy } dotest -{ 1 array 1 array readonly copy } dotest -{ 1 dict noaccess 1 dict copy } dotest -{ 1 dict 1 dict readonly copy } dotest -{ 1 string executeonly 1 string copy } dotest -{ 1 string 1 string readonly copy } dotest -{ (100) executeonly cvi } dotest -{ (string) executeonly cvn } dotest -{ (100.001) executeonly cvr } dotest -{ 1 10 1 string readonly cvrs } dotest -{ true 5 string readonly cvs } dotest -{ 1 dict readonly begin /foo true def } dotest -{ 10 array readonly dictstack } dotest -{ 1 string executeonly 1 string eq } dotest -{ 1 string 1 string executeonly eq } dotest -{ 10 array readonly execstack } dotest -{ 1 string noaccess executeonly } dotest -{ 1 array noaccess executeonly } dotest -{ 1 array executeonly { pop } forall } dotest -{ 1 dict noaccess { pop pop } forall } dotest -{ 1 string executeonly { pop } forall } dotest -{ (string1) executeonly (string2) ge } dotest -{ (string1) (string2) executeonly ge } dotest -{ 1 array executeonly 0 get } dotest -{ 1 dict noaccess /key get } dotest -{ 1 string executeonly 0 get } dotest -{ 1 array executeonly 0 1 getinterval } dotest -{ 1 string executeonly 0 1 getinterval } dotest -{ (string1) executeonly (string2) gt } dotest -{ (string1) (string2) executeonly gt } dotest -{ 1 dict noaccess /key known } dotest -{ {} (string) executeonly kshow } dotest -{ (string1) executeonly (string2) le } dotest -{ (string1) (string2) executeonly le } dotest -{ 1 array executeonly length } dotest -{ 1 dict noaccess length } dotest -{ 1 string executeonly length } dotest -%%{ /foo 1 dict def foo begin /bar foo def bar noaccess pop /key load } dotest -{ (string1) executeonly (string2) lt } dotest -{ (string1) (string2) executeonly lt } dotest -{ 1 dict noaccess maxlength } dotest -{ 1 string executeonly 1 string ne } dotest -{ 1 string 1 string executeonly ne } dotest -%{ newpath 0 0 moveto (a) false charpath -% {} {} {} {} pathforall closepath } dotest -{ 1 array executeonly 0 put } dotest -{ 1 dict noaccess /key put } dotest -{ 1 string executeonly 0 put } dotest -{ 1 array executeonly 0 1 putinterval } dotest -{ 1 string executeonly 0 1 putinterval } dotest -{ (access.ps) (r) file executeonly read } dotest -{ (access.ps) (r) file executeonly 10 string readhexstring } dotest -{ (access.ps) (r) file 10 string readonly readhexstring } dotest -{ (access.ps) (r) file executeonly 100 string readline } dotest -{ (access.ps) (r) file 100 string readonly readline } dotest -{ (access.ps) (r) file executeonly 10 string readstring } dotest -{ (access.ps) (r) file 10 string readonly readstring } dotest -% run does not check for no read access? -{ (string) executeonly (seek) search } dotest -{ (string) (seek) executeonly search } dotest -{ (string) executeonly show } -%% some test for store. -{ (string) executeonly stringwidth } dotest -{ (access.ps) (r) file executeonly token } dotest -{ (10) executeonly token } dotest -{ /foo 1 dict def foo begin /bar foo def bar noaccess pop /key where } dotest -{ 100 101 102 (string) noaccess widthshow } dotest -{ (/tmp/_.ps) noaccess (w) file closefile } dotest -{ (/tmp/_.ps) (w) noaccess file closefile } dotest -{ (/tmp/_.ps) (w) file executeonly 100 write } dotest -{ (/tmp/_.ps) (w) file executeonly 10 string writehexstring } dotest -{ (/tmp/_.ps) (w) file 10 string executeonly writehexstring } dotest -{ (/tmp/_.ps) (w) file executeonly 10 string writestring } dotest -{ (/tmp/_.ps) (w) file 10 string executeonly writestring } dotest diff --git a/dist/conf/ghostscript/lib/align.ps b/dist/conf/ghostscript/lib/align.ps deleted file mode 100644 index ae5b21e..0000000 --- a/dist/conf/ghostscript/lib/align.ps +++ /dev/null @@ -1,72 +0,0 @@ -% Copyright (C) 2001-2023 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, -% CA 94129, USA, for further information. -% - -% Print a page that indicates the proper settings of Margins and HWMargins -% for a given device. Requires a Level 2 system. - -% Reset the offset and margins. - -<< - /PageOffset [0 0] - /Margins [0 0] - /.HWMargins [0 0 0 0] ->> -setpagedevice -<< - /ImagingBBox null ->> -setpagedevice - -% Determine the actual page size. - -clippath pathbbox newpath -/y1 exch def /x1 exch def pop pop - -% Draw lines that should be exactly 1" in from each edge, -% and should extend precisely to the edge of the paper. - -1 setlinewidth -0 setgray -72 0 moveto 0 y1 rlineto stroke -0 72 moveto x1 0 rlineto stroke - -% Print the text in the middle of the page. - -/S 80 string def -108 480 moveto -/Helvetica 12 selectfont - { currentfile S readline pop dup (%END) eq { pop exit } if - gsave show grestore 0 -15 rmoveto - } loop -Let the distance in inches from the left edge of the page to -the vertical line be H, and from the bottom edge to the -horizontal line be V; let the lengths of the gaps at the top -and bottom of the vertical line be T and B respectively, and -the gaps at the left and right of the horizontal line be L -and R. For correct alignment of pages, put the following line -in a file named (for example) margins.ps, and then mention -margins.ps on the gs command line when printing any of your -own files: - - << /.HWMargins [ml mb mr mt] /Margins [x y] >> setpagedevice - -where - ml = L * 72, mb = B * 72, mr = R * 72, mt = T * 72, -%END -/res currentpagedevice /HWResolution get def -( x = (1 - H) * ) show res 0 get =string cvs show -(, y = (V - 1) * ) show res 1 get =string cvs show - -showpage diff --git a/dist/conf/ghostscript/lib/caption.ps b/dist/conf/ghostscript/lib/caption.ps deleted file mode 100644 index 72b117b..0000000 --- a/dist/conf/ghostscript/lib/caption.ps +++ /dev/null @@ -1,58 +0,0 @@ -%! -% Copyright (C) 2001-2023 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, -% CA 94129, USA, for further information. -% - -% Add a "caption" to the bottom of each page. -/captionsize 20 def -/caption - { /Helvetica //captionsize selectfont - (Printed by Artifex's XXYYZZ) show - /Symbol //captionsize selectfont - (\324) show % trademarkserif - /Helvetica //captionsize selectfont - ( product) show - } bind def - -10 dict begin -gsave - initgraphics - clippath pathbbox - pop exch 36 add /by exch def - % We can't use stringwidth, so we have to show and measure. - gsave - 0 0 0 0 rectclip - 0 0 moveto caption currentpoint pop /bw exch def - grestore - add bw sub 2 div /bx exch def - % We don't have the font bbox available, so we guess. - /bh captionsize 1.05 mul def -grestore -/showcaption - { gsave - initgraphics - //bx 9 sub //by 9 sub //bw 18 add //bh 18 add - 1 setgray 4 copy rectfill 0 setgray 1.5 setlinewidth rectstroke - //bx //by moveto //caption exec - grestore - } bind def -<< /EndPage [ - %% - %% Only print the caption if 'reason' is not 2 (device deactivation) - %% - /dup load /exec load 2 /ne load /exec load [ /showcaption load /exec load ] cvx /if load /exec load - currentpagedevice /EndPage get /exec load - ] cvx ->> setpagedevice -end diff --git a/dist/conf/ghostscript/lib/cat.ps b/dist/conf/ghostscript/lib/cat.ps deleted file mode 100644 index fd3698d..0000000 --- a/dist/conf/ghostscript/lib/cat.ps +++ /dev/null @@ -1,74 +0,0 @@ -% Copyright (C) 2001-2023 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, -% CA 94129, USA, for further information. -% -% -% $Id: cat.ps 8331 2008-02-05 11:07:00Z kens $ -% -% Appends one file to another. Primarily used to overcome the -% 'copy' limitation of Windows command shell for ps2epsi -% -% the files to be appended are given by the environament -% variables %infile% and %outfile%. %infile% is appended to -% %outfile% -% - -/datastring 1024 string def - -{ - (outfile) getenv - { - /outfilename exch def - (infile) getenv - { - /infilename exch def - - infilename status - { - pop pop pop pop outfilename status - { - pop pop pop pop - infilename (r) file /infile exch def - outfilename (a+) file /outfile exch def - { - infile datastring readstring - { - outfile exch writestring - } - { - dup length 0 gt - {outfile exch writestring} {pop} ifelse - exit - } ifelse - } loop - infile closefile - outfile closefile - } - { - (Failed to find file ) print outfilename == - } ifelse - } - { - (Failed to find file ) print infilename == - } ifelse - } - { - (Couldn't find %infile% environment variable) == - } ifelse - } - { - (Couldn't find %outfile% environment variable) == - } - ifelse -} bind -exec diff --git a/dist/conf/ghostscript/lib/cid2code.ps b/dist/conf/ghostscript/lib/cid2code.ps deleted file mode 100644 index cafc92d..0000000 --- a/dist/conf/ghostscript/lib/cid2code.ps +++ /dev/null @@ -1,159 +0,0 @@ -% Copyright (C) 2001-2023 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, -% CA 94129, USA, for further information. -% - -% Construct an inverse map from CIDs to codes. - -% Create an inverse map from CIDs to code values. -% We only use this for 16-bit Unicode, so it has some limitations. -% After invoking .cmap2code, loading a CMap file prints out the map -% instead of doing what it usually does. For example: -% -% gs -dNODISPLAY -dBATCH lib/cid2code.ps -c .cmap2code\ -% -f Resource/CMap/UniJIS-UCS2-H > mapfile - -/.cmap2codedict 10 dict begin - -/begincmap { - mark -} def -/endcmap { - % Stack: mark code_lo1 code_hi1 cid1 ... - 20 dict begin - /depth counttomark 3 sub def - % Do a first pass to determine the maximum CID. - 0 0 3 depth { - 1 add /d exch def - d index d 2 add index 1 get add d 3 add index 1 get sub .max - } for - 1 add /ncid exch def - /map ncid 2 mul string def - % Now fill in the map. - 0 3 depth { - /d exch def - d index 2 mul /cid2 exch def - d 1 add index /hi exch def - d 2 add index 2 string copy /lo exch def - lo 1 get 1 hi 1 get { - map cid2 lo 0 get put - map cid2 1 add 3 -1 roll put - /cid2 cid2 2 add def - } for - } for - % Print the map. - (%stdout) (w) file - dup (<) print - dup /ASCIIHexEncode filter - dup map writestring - closefile - () = flush - closefile - end -} def -%/begincodespacerange -/endcodespacerange {cleartomark} def -%/usecmap - -%/beginbfchar -/endbfchar {cleartomark} def -%/beginbfrange -/endbfrange {cleartomark} def - -%/begincidchar -/endcidchar { - counttomark 2 idiv { dup counttomark 1 add 3 roll } repeat pop -} def -%/begincidrange -/endcidrange { - counttomark 1 add -1 roll pop -} def - -%/beginnotdefchar -/endnotdefchar {cleartomark} def -%/beginnotdefrange -/endnotdefrange {cleartomark} def - -currentdict end readonly def - -/.cmap2code { % - .cmap2code - - /CIDInit /ProcSet findresource dup length dict copy - .cmap2codedict { 3 copy put pop pop } forall - /CIDInit exch /ProcSet defineresource pop -} def - -% Extract and print reverse mapping information from a cid2code.txt file. -/.printhex2 { % .printhex2 - - (<) print - 16#10000 add 16 =string cvrs 1 4 getinterval print - (>) print -} def -/.cid2code { % .cid2code - - 30 dict begin - /column exch def - (r) file /f exch def - (%!) = - (/CIDInit /ProcSet findresource begin 12 dict begin begincmap) = - % Print the information from the template. - { - exch ==only ( ) print - dup type /dicttype eq { - dup length =only ( dict dup begin) = { - ( ) print exch ===only ( ) print ===only ( def) = - } forall (end def) = - } { - ===only - } ifelse ( def) = - } forall - % Read the data from the cid2code.txt file. - { - f =string readline pop (CID\t) anchorsearch { pop pop exit } if pop - } loop - /map [ { - f =string readline not { pop exit } if - column { (\t) search pop pop pop } repeat - (\t) search { exch pop exch pop } if - (,) search { exch pop exch pop } if - dup length 4 ne { pop (*) } if - dup (*) eq { pop (0000) } if - (16#) exch concatstrings cvi - } loop ] def - % Print the code space range(s). - /maxcid map length 1 sub def - mark maxcid - dup 255 and 255 eq { - 0 exch - } { - dup 16#ff00 and exch 0 2 index 1 sub - } ifelse - counttomark 2 idiv dup =only ( begincodespacerange) = { - exch .printhex2 .printhex2 () = - } repeat (endcodespacerange) = - % Print the map data. - 0 1 100 maxcid { - /lo exch def - /hi lo 99 add maxcid .min def - 0 lo 1 hi { map exch get 0 ne { 1 add } if } for - dup 0 eq { - pop - } { - =only ( begincidchar) = lo 1 hi { - map 1 index get dup 0 eq { pop pop } { exch .printhex2 = } ifelse - } for (endcidchar) = - } ifelse - } for - % Wrap up. - (endcmap CMapName currentdict /CMap defineresource pop end end) = - f closefile - end -} bind def diff --git a/dist/conf/ghostscript/lib/docie.ps b/dist/conf/ghostscript/lib/docie.ps deleted file mode 100644 index 7f7f4d4..0000000 --- a/dist/conf/ghostscript/lib/docie.ps +++ /dev/null @@ -1,219 +0,0 @@ -% Copyright (C) 2001-2023 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, -% CA 94129, USA, for further information. -% - -% docie.ps -% Emulate CIE algorithms in PostScript. - -% ---------------- Auxiliary procedures ---------------- % - -/r1default [0 1] def -/r3default [0 1 0 1 0 1] def - -/apply3 % [ ] apply3 - { { 4 -1 roll exch exec } forall - } bind def - -/restrict % restrict - { 3 1 roll .max .min - } bind def - -/restrict3 % [ ... ] restrict3 - { aload pop - 7 -1 roll 3 1 roll restrict 7 1 roll - 5 -1 roll 3 1 roll restrict 5 1 roll - restrict 3 1 roll - } bind def - -/rescale % rescale - { 1 index sub 3 1 roll sub exch div 0 .max 1 .min - } bind def - -/rescale3 % [ ... ] rescale3 - { aload pop - 7 -1 roll 3 1 roll rescale 7 1 roll - 5 -1 roll 3 1 roll rescale 5 1 roll - rescale 3 1 roll - } bind def - -/mmult3 % [ ... ] mmult3 - % - { 4 -1 roll dup dup 6 -1 roll dup dup 8 -1 roll dup dup - 10 -1 roll { 10 -1 roll mul } forall - % Stack: u1 v1 w1 u2 v2 w2 u3 v3 w3 - 4 -1 roll add 6 -1 roll add - % Stack: u1 v1 u2 v2 u3 v3 w' - 7 1 roll 3 -1 roll add 4 -1 roll add - % Stack: w' u1 u2 u3 v' - 5 1 roll add add 3 1 roll - } bind def - -/minvert3 % [ ... ] minvert3 - % [ ... ] - { 16 dict begin - aload pop { I H G F E D C B A } { exch def } forall - /coa E I mul F H mul sub def - /cob F G mul D I mul sub def - /coc D H mul E G mul sub def - /det A coa mul B cob mul add C coc mul add def - [ coa det div - C H mul B I mul sub det div - B F mul C E mul sub det div - cob det div - A I mul C G mul sub det div - C D mul A F mul sub det div - coc det div - B G mul A H mul sub det div - A E mul B D mul sub det div - ] - end - } bind def - -/print1 - { print dup == - } bind def - -/print3 - { print 3 array astore dup == aload pop - } bind def - -% ---------------- Mapping to XYZ ---------------- % - -/csmap % csmap - { 3 index /RangeLMN .knownget not { r3default } if restrict3 -DOCIEDEBUG { (After RangeLMN Decode: ) print3 } if - 3 index /DecodeLMN .knownget { apply3 } if -DOCIEDEBUG { (After DecodeLMN Decode: ) print3 } if - 3 index /MatrixLMN .knownget { mmult3 } if -DOCIEDEBUG { (After MatrixLMN Decode: ) print3 } if - } bind def - -/csciea % csciea - { 1 index /RangeA .knownget not { r1default aload pop } if restrict -DOCIEDEBUG { (After RangeA Decode: ) print1 } if - 1 index /DecodeA .knownget { exec } if -DOCIEDEBUG { (After DecodeA Decode: ) print1 } if - 1 index /MatrixA .knownget - { { 1 index mul exch } forall pop } - { dup dup } - ifelse -DOCIEDEBUG { (After MatrixA Decode: ) print3 } if - csmap - } bind def - -/cscieabc % cscieabc - { 3 index /RangeABC .knownget not { r3default } if restrict3 -DOCIEDEBUG { (After RangeABC Decode: ) print3 } if - 3 index /DecodeABC .knownget { apply3 } if -DOCIEDEBUG { (After DecodeABC Decode: ) print3 } if - 3 index /MatrixABC .knownget { mmult3 } if -DOCIEDEBUG { (After MatrixABC Decode: ) print3 } if - csmap - } bind def - -% ---------------- Rendering from XYZ ---------------- % - -/lookup3 % lookup3 - % - { 3 -1 roll 3 index 0 get 1 sub mul - 3 -1 roll 3 index 1 get 1 sub mul - 3 -1 roll 3 index 2 get 1 sub mul - % Stack: rtable ia ib ic -DOCIEDEBUG { (RenderTable indices: ) print3 mark 5 1 roll } if - 3 -1 roll round cvi 3 index 3 get exch get - % Stack: rtable ib ic string - 3 -1 roll round cvi 3 index 2 get mul - % Stack: rtable ic string ib*nc - 3 -1 roll round cvi add 2 index 4 get mul - % Stack: rtable string index - 2 index 4 get getinterval - % Stack: rtable bytes -DOCIEDEBUG { (RenderTable values: ) print (<) print (%stdout) (w) file 1 index writehexstring (>) = } if - } bind def - -/bpdefault [0 0 0] def - -/crmap % crmap ... - { -DOCIEDEBUG { (CIE XYZ = ) print3 } if - 3 index /MatrixPQR .knownget { mmult3 } if -DOCIEDEBUG { (After MatrixPQR: ) print3 } if - 4 index /WhitePoint get - 5 index /BlackPoint .knownget not { bpdefault } if - 5 index /WhitePoint get - 6 index /BlackPoint .knownget not { bpdefault } if - 4 - { 4 -1 roll aload pop - % Stack: csdict crdict x y z pt pt pt px py pz - 3 copy 12 index /MatrixPQR .knownget { mmult3 } if 6 array astore - } - repeat - % Stack: csdict crdict x y z wps+ bps+ wpd+ bpd+ - 9 -1 roll pop % get rid of csdict - 7 4 roll - 7 index /TransformPQR get - { % Stack: crdict wps+ bps+ wpd+ bpd+ u v w proc - 8 copy exch pop exch pop - exec exch pop 4 -1 roll pop - } - forall - 7 3 roll pop pop pop pop % get rid of White/BlackPoints -DOCIEDEBUG { (After TransformPQR: ) print3 } if - 3 index /MatrixPQR .knownget { minvert3 mmult3 } if -DOCIEDEBUG { (After MatrixPQR': ) print3 } if - 3 index /MatrixLMN .knownget { mmult3 } if -DOCIEDEBUG { (After MatrixLMN Encode: ) print3 } if - 3 index /EncodeLMN .knownget { apply3 } if -DOCIEDEBUG { (After EncodeLMN Encode: ) print3 } if - 3 index /RangeLMN .knownget not { r3default } if restrict3 -DOCIEDEBUG { (After RangeLMN Encode: ) print3 } if - 3 index /MatrixABC .knownget { mmult3 } if -DOCIEDEBUG { (After MatrixABC Encode: ) print3 } if - 3 index /EncodeABC .knownget { apply3 } if -DOCIEDEBUG { (After EncodeABC Encode: ) print3 } if - 3 index /RangeABC .knownget not { r3default } if - 5 -1 roll /RenderTable .knownget - { % Stack: u v w ranges rtable - 5 1 roll rescale3 -DOCIEDEBUG { (Rescaled ABC: ) print3 } if - % Stack: rtable a b c - lookup3 - % Stack: rtable bytes - 0 1 3 index 4 get 1 sub - { % Stack: values rtable bytes c - 2 copy get 255 div - % Stack: values rtable bytes c v - 3 index 3 -1 roll 5 add get exec 3 1 roll - } - for pop pop -DOCIEDEBUG { (After RenderTableT: ) print ] dup == aload pop } if - } - { restrict3 -DOCIEDEBUG { (After RangeABC Encode: ) print3 } if - } - ifelse - } bind def - -% ---------------- Top level control ---------------- % - -/mapdict mark - /CIEBasedA { 1 get exch csciea currentcolorrendering 4 1 roll crmap } bind - /DeviceGray { pop /DefaultGray /ColorSpace findresource 1 get exch csciea currentcolorrendering 4 1 roll crmap } bind - /CIEBasedABC { 1 get 4 1 roll cscieabc currentcolorrendering 4 1 roll crmap } bind - /DeviceRGB { pop /DefaultRGB /ColorSpace findresource 1 get 4 1 roll cscieabc currentcolorrendering 4 1 roll crmap } bind -.dicttomark def -/mapcie % mapcie ... - % mapcie ... - { currentcolorspace dup 0 get //mapdict exch get exec - } bind def diff --git a/dist/conf/ghostscript/lib/font2pcl.ps b/dist/conf/ghostscript/lib/font2pcl.ps deleted file mode 100644 index 1d15453..0000000 --- a/dist/conf/ghostscript/lib/font2pcl.ps +++ /dev/null @@ -1,606 +0,0 @@ -% Copyright (C) 2001-2023 Artifex Software, Inc. -% All Rights Reserved. -% -% This software is provided AS-IS with no warranty, either express or -% implied. -% -% This software is distributed under license and may not be copied, -% modified or distributed except as expressly authorized under the terms -% of the license contained in the file LICENSE in this distribution. -% -% Refer to licensing information at http://www.artifex.com or contact -% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, -% CA 94129, USA, for further information. -% - -% font2pcl.ps -% Write out a font as a PCL bitmap font. -% This program must be run with -dNOSAFER, as it uses the in-memory image device -% which is unavailable with SAFER. - -/pcldict 60 dict def - -% Write out the current font as a PCL bitmap font. -% The current transformation matrix defines the font size and orientation. - -/WriteResolution? false def % true=use "resolution bound font" format, - % false=use older format - -/LJ4 false def % true=use LJ4 Typeface code - % false=use LJIIP/IID/IIIx Typeface code - -pcldict begin % internal procedures - -/findstring % findstring - { search { pop pop pop true } { pop false } ifelse - } def - - % Determine which set of keywords is present in a string. - % The last keyword set must be empty. - -/keysearch % keysearch - { 0 1 2 index length 1 sub - { 2 copy get true exch - { % Stack: - 4 index exch findstring and - } - forall - { 0 exch getinterval exit - } - if pop - } - for - exch pop length % invalid index if missing - } def - - % Determine the device height of a string in quarter-dots. - -/charheight % charheight - { gsave newpath 0 0 moveto false charpath - pathbbox exch pop exch sub exch pop 0 exch grestore - dtransform add abs 4 mul cvi - } def - - % Compute an integer version of the transformed FontBBox. - -/inflate % inflate - { dup 0 gt { ceiling } { floor } ifelse - } def -/ixbbox % - ixbbox - { /FontBBox load aload pop % might be executable or literal - 4 2 roll transform exch truncate cvi exch truncate cvi - 4 2 roll transform exch inflate cvi exch inflate cvi - } def - - % Determine the original font of a possibly transformed font. - % Since some badly behaved PostScript files construct transformed - % fonts "by hand", we can't just rely on the OrigFont pointers. - % Instead, if a font with the given name exists, and if its - % entries for FontType and UniqueID match those of the font we - % obtain by following the OrigFont chain, we use that font. - -/origfont - { { dup /OrigFont known not { exit } if /OrigFont get } loop - FontDirectory 1 index /FontName get .knownget - { % Stack: origfont namedfont - 1 index /FontType get 1 index /FontType get eq - { 1 index /UniqueID .knownget - { 1 index /UniqueID .knownget - { eq { exch } if } - { pop } - ifelse - } - if - } - if pop - } - if - } def - - % Determine the bounding box of the current device's image. - % Free variables: row, zerow. - -/devbbox % devbbox - { % Find top and bottom whitespace. - dup - { dup 0 eq { exit } if 1 sub - dup currentdevice exch row copyscanlines - zerow ne { 1 add exit } if - } - loop % ymax1 - 0 - { 2 copy eq { exit } if - dup currentdevice exch row copyscanlines - zerow ne { exit } if - 1 add - } - loop % ymin - exch - % Find left and right whitespace. - 3 index 0 - % Stack: rw rh ymin ymax1 xmin xmax1 - 3 index 1 4 index 1 sub - { currentdevice exch row copyscanlines .findzeros - exch 4 1 roll .max 3 1 roll .min exch - } - for % xmin xmax1 - % Special check: xmin > xmax1 if height = 0 - 2 copy gt { exch pop dup } if - 6 -2 roll pop pop - - } def - - % Write values on outfile. - - /w1 { 255 and outfile exch write } def - /w2 { dup -8 bitshift w1 w1 } def - /wbyte %