コード例 #1
0
        public void Close()
        {
            if (_formatHandler != null)
            {
                _formatHandler = null;
            }

            if (_interpreter != null)
            {
                _interpreter.Dispose();
                _interpreter = null;
            }
        }
コード例 #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (_formatHandler != null)
                    {
                        _formatHandler.Dispose();
                        _formatHandler = null;
                    }

                    if (_interpreter != null)
                    {
                        _interpreter.Dispose();
                        _interpreter = null;
                    }
                }

                _disposed = true;
            }
        }
コード例 #3
0
 public GhostscriptViewerStdIOHandler(GhostscriptViewer viewer, GhostscriptViewerFormatHandler formatHandler) : base(true, true, true)
 {
     _viewer = viewer;
     _formatHandler = formatHandler;
 }
コード例 #4
0
 public GhostscriptViewerStdIOHandler(GhostscriptViewer viewer, GhostscriptViewerFormatHandler formatHandler) : base(true, true, true)
 {
     _viewer        = viewer;
     _formatHandler = formatHandler;
 }
コード例 #5
0
        private void Open()
        {
            string extension = Path.GetExtension(_filePath).ToLower();

            if (!string.IsNullOrWhiteSpace(_filePath) && string.IsNullOrWhiteSpace(extension))
            {
                using (FileStream srm = new FileStream(_filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    extension = StreamHelper.GetStreamExtension(srm);
                }
            }

            switch (extension)
            {
            case ".pdf":
            {
                _formatHandler = new GhostscriptViewerPdfFormatHandler(this);
                break;
            }

            case ".ps":
            {
                _formatHandler = new GhostscriptViewerPsFormatHandler(this);
                break;
            }

            case ".eps":
            {
                _formatHandler = new GhostscriptViewerEpsFormatHandler(this);
                break;
            }

            default:
            {
                _formatHandler = new GhostscriptViewerDefaultFormatHandler(this);
                break;
            }
            }

            _interpreter.Setup(new GhostscriptViewerStdIOHandler(this, _formatHandler), new GhostscriptViewerDisplayHandler(this));

            List <string> args = new List <string>();

            args.Add("-gsnet");
            args.Add("-sDEVICE=display");

            if (Environment.Is64BitProcess)
            {
                args.Add("-sDisplayHandle=0");
            }
            else
            {
                args.Add("-dDisplayHandle=0");
            }

            args.Add("-dDisplayFormat=" +
                     ((int)DISPLAY_FORMAT_COLOR.DISPLAY_COLORS_RGB |
                      (int)DISPLAY_FORMAT_ALPHA.DISPLAY_ALPHA_NONE |
                      (int)DISPLAY_FORMAT_DEPTH.DISPLAY_DEPTH_8 |
                      (int)DISPLAY_FORMAT_ENDIAN.DISPLAY_LITTLEENDIAN |
                      (int)DISPLAY_FORMAT_FIRSTROW.DISPLAY_BOTTOMFIRST).ToString());

            args.Add("-dDOINTERPOLATE");

            // fixes bug: http://bugs.ghostscript.com/show_bug.cgi?id=695180
            if (_interpreter.LibraryRevision > 910)
            {
                args.Add("-dMaxBitmap=1g");
            }

            _interpreter.InitArgs(args.ToArray());

            _formatHandler.Initialize();

            _formatHandler.Open(_filePath);

            if (_showPageAfterOpen)
            {
                this.ShowPage(_formatHandler.FirstPageNumber, true);
            }
        }
コード例 #6
0
        private void Open()
        {
            string extension = Path.GetExtension(_filePath).ToLower();

            switch (extension)
            {
            case ".pdf":
            {
                _formatHandler = new GhostscriptViewerPdfFormatHandler(this);
                break;
            }

            case ".ps":
            {
                _formatHandler = new GhostscriptViewerPsFormatHandler(this);
                break;
            }

            default:
            {
                _formatHandler = new GhostscriptViewerDefaultFormatHandler(this);
                break;
            }
            }

            _interpreter.Setup(new GhostscriptViewerStdIOHandler(this, _formatHandler), new GhostscriptViewerDisplayHandler(this));

            List <string> args = new List <string>();

            args.Add("GSNET");
            args.Add("-sDEVICE=display");

            if (Environment.Is64BitProcess)
            {
                args.Add("-sDisplayHandle=0");
            }
            else
            {
                args.Add("-dDisplayHandle=0");
            }

            args.Add("-dDisplayFormat=" +
                     ((int)DISPLAY_FORMAT_COLOR.DISPLAY_COLORS_RGB |
                      (int)DISPLAY_FORMAT_ALPHA.DISPLAY_ALPHA_NONE |
                      (int)DISPLAY_FORMAT_DEPTH.DISPLAY_DEPTH_8 |
                      (int)DISPLAY_FORMAT_ENDIAN.DISPLAY_LITTLEENDIAN |
                      (int)DISPLAY_FORMAT_FIRSTROW.DISPLAY_BOTTOMFIRST).ToString());
            //args.Add("-dNOINTERPOLATE");
            //args.Add("-dCOLORSCREEN=0");
            //args.Add("-dAlignToPixels=0");

            args.Add("-dDOINTERPOLATE");
            args.Add("-dTextAlphaBits=4");
            args.Add("-dGraphicAlphaBits=4");
            //args.Add("-dGridFitTT=0");
            //args.Add("-dHaveTrueTypes=true");

            _interpreter.InitArgs(args.ToArray());

            _formatHandler.Initialize();
            _formatHandler.Open(_filePath);

            this.ShowPage(_formatHandler.FirstPageNumber, true);
        }
コード例 #7
0
        public void Close()
        {
            if (_formatHandler != null)
            {
                _formatHandler = null;
            }

            if (_interpreter != null)
            {
                _interpreter.Dispose();
                _interpreter = null;
            }
        }
コード例 #8
0
        private void Open()
        {
            string extension = Path.GetExtension(_filePath).ToLower();

            if (!string.IsNullOrWhiteSpace(_filePath) && string.IsNullOrWhiteSpace(extension))
            {
                using (FileStream srm = new FileStream(_filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    extension = StreamHelper.GetStreamExtension(srm);
                }
            }

            switch (extension)
            {
                case ".pdf":
                    {
                        _formatHandler = new GhostscriptViewerPdfFormatHandler(this);
                        break;
                    }
                case ".ps":
                    {
                        _formatHandler = new GhostscriptViewerPsFormatHandler(this);
                        break;
                    }
                case ".eps":
                    {
                        _formatHandler = new GhostscriptViewerEpsFormatHandler(this);
                        break;
                    }
                default:
                    {
                        _formatHandler = new GhostscriptViewerDefaultFormatHandler(this);
                        break;
                    }
            }

            _interpreter.Setup(new GhostscriptViewerStdIOHandler(this, _formatHandler), new GhostscriptViewerDisplayHandler(this));

            List<string> args = new List<string>();
            args.Add("-gsnet");
            args.Add("-sDEVICE=display");

            if (Environment.Is64BitProcess)
            {
                args.Add("-sDisplayHandle=0");
            }
            else
            {
                args.Add("-dDisplayHandle=0");
            }

            args.Add("-dDisplayFormat=" +
                        ((int)DISPLAY_FORMAT_COLOR.DISPLAY_COLORS_RGB |
                        (int)DISPLAY_FORMAT_ALPHA.DISPLAY_ALPHA_NONE |
                        (int)DISPLAY_FORMAT_DEPTH.DISPLAY_DEPTH_8 |
                        (int)DISPLAY_FORMAT_ENDIAN.DISPLAY_LITTLEENDIAN |
                        (int)DISPLAY_FORMAT_FIRSTROW.DISPLAY_BOTTOMFIRST).ToString());

            args.Add("-dDOINTERPOLATE");
            args.Add("-dGridFitTT=0");

            // fixes bug: http://bugs.ghostscript.com/show_bug.cgi?id=695180
            if (_interpreter.LibraryRevision > 910)
            {
                args.Add("-dMaxBitmap=1g");
            }

            foreach(string customSwitch in _customSwitches)
            {
                args.Add(customSwitch);
            }

            _interpreter.InitArgs(args.ToArray());

            _formatHandler.Initialize();

            _formatHandler.Open(_filePath);

            if (_showPageAfterOpen)
            {
                this.ShowPage(_formatHandler.FirstPageNumber, true);
            }
        }
コード例 #9
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    if (_formatHandler != null)
                    {
                        _formatHandler.Dispose();
                        _formatHandler = null;
                    }

                    if (_interpreter != null)
                    {
                        _interpreter.Dispose();
                        _interpreter = null;
                    }
                }

                _fileCleanupHelper.Cleanup();

                _disposed = true;
            }
        }
コード例 #10
0
        private void Open()
        {
            string extension = "";

            if (!String.IsNullOrEmpty(_filePath))
            {
                extension = Path.GetExtension(_filePath).ToLower();

                if (!string.IsNullOrWhiteSpace(_filePath) && string.IsNullOrWhiteSpace(extension))
                {
                    using (FileStream srm = new FileStream(_filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        extension = StreamHelper.GetStreamExtension(srm);
                    }
                }
            }

            switch (extension)
            {
            case ".pdf":
            {
                _formatHandler = new GhostscriptViewerPdfFormatHandler(this);
                break;
            }

            case ".ps":
            {
                _formatHandler = new GhostscriptViewerPsFormatHandler(this);
                break;
            }

            case ".eps":
            {
                _formatHandler = new GhostscriptViewerEpsFormatHandler(this);
                break;
            }

            default:
            {
                _formatHandler = new GhostscriptViewerDefaultFormatHandler(this);
                break;
            }
            }

            GhostscriptStdIO _stdIOhandler = new GhostscriptViewerStdIOHandler(this, _formatHandler);

            _interpreter.Setup(_stdIOhandler, new GhostscriptViewerDisplayHandler(this));

            List <string> args = new List <string>();

            //args.Add("-gsnet");
            args.Add("-sDEVICE=display");

            if (Environment.Is64BitProcess)
            {
                args.Add("-sDisplayHandle=0");
            }
            else
            {
                args.Add("-dDisplayHandle=0");
            }

            args.Add("-dDisplayFormat=" +
                     ((int)DISPLAY_FORMAT_COLOR.DISPLAY_COLORS_RGB |
                      (int)DISPLAY_FORMAT_ALPHA.DISPLAY_ALPHA_NONE |
                      (int)DISPLAY_FORMAT_DEPTH.DISPLAY_DEPTH_8 |
                      (int)DISPLAY_FORMAT_ENDIAN.DISPLAY_LITTLEENDIAN |
                      (int)DISPLAY_FORMAT_FIRSTROW.DISPLAY_BOTTOMFIRST).ToString());

            args.Add("-dInterpolateControl=1");
            args.Add("-dTextAlphaBits=4");
            args.Add("-dGraphicsAlphaBits=4");
            args.Add("-dGridFitTT=2");              // was 0, but use font hinting; https://www.ghostscript.com/doc/9.52/Language.htm#GridFitTT

            if (!String.IsNullOrEmpty(_filePath))
            {
                string basedir = Path.GetDirectoryName(_filePath).Replace("\\", "/");
#if false   // somehow the --permit-file-XXX commandline parameters are not picked up all the time, while -I work better    :-S
                args.Add($"--permit-file-all={ basedir }");
#else
                args.Add($"-I{ basedir }");
#endif
            }

            // fixes bug: http://bugs.ghostscript.com/show_bug.cgi?id=695180
            if (_interpreter.LibraryRevision > 910 && _interpreter.LibraryRevision <= 921)
            {
                args.Add("-dMaxBitmap=1g");
            }
            else
            {
                // assume a 4K screen+50%
                args.Add($"-dMaxBitmap={ (int)(4096 * 2160 * 4 * 1.5) }");
            }

            foreach (string customSwitch in _customSwitches)
            {
                args.Add(customSwitch);
            }

            _interpreter.InitArgs(args.ToArray());

            _formatHandler.Initialize();

            _formatHandler.Open(_filePath);

            if (_showPageAfterOpen)
            {
                this.ShowPage(_formatHandler.FirstPageNumber, true);
            }
        }
コード例 #11
0
        private void Open()
        {
            string extension = Path.GetExtension(_filePath).ToLower();

            switch (extension)
            {
                case ".pdf":
                    {
                        _formatHandler = new GhostscriptViewerPdfFormatHandler(this);
                        break;
                    }
                case ".ps":
                    {
                        _formatHandler = new GhostscriptViewerPsFormatHandler(this);
                        break;
                    }
                case ".eps":
                    {
                        _formatHandler = new GhostscriptViewerEpsFormatHandler(this);
                        break;
                    }
                default:
                    {
                        _formatHandler = new GhostscriptViewerDefaultFormatHandler(this);
                        break;
                    }
            }

            _interpreter.Setup(new GhostscriptViewerStdIOHandler(this, _formatHandler), new GhostscriptViewerDisplayHandler(this));

            List<string> args = new List<string>();
            args.Add("-gsnet");
            args.Add("-sDEVICE=display");

            if (Environment.Is64BitProcess)
            {
                args.Add("-sDisplayHandle=0");
            }
            else
            {
                args.Add("-dDisplayHandle=0");
            }

            args.Add("-dDisplayFormat=" +
                        ((int)DISPLAY_FORMAT_COLOR.DISPLAY_COLORS_RGB |
                        (int)DISPLAY_FORMAT_ALPHA.DISPLAY_ALPHA_NONE |
                        (int)DISPLAY_FORMAT_DEPTH.DISPLAY_DEPTH_8 |
                        (int)DISPLAY_FORMAT_ENDIAN.DISPLAY_LITTLEENDIAN |
                        (int)DISPLAY_FORMAT_FIRSTROW.DISPLAY_BOTTOMFIRST).ToString());

            args.Add("-dDOINTERPOLATE");

            //args.Add("-dDELAYBIND");
            //args.Add("-dWRITESYSTEMDICT");
            //args.Add("-q");
            //args.Add("-dFIXEDMEDIA");

            //args.Add("-sDEFAULTPAPERSIZE=a3");

            //args.Add("-dDEVICEWIDTHPOINTS=2000");
            //args.Add("-dDEVICEHEIGHTPOINTS=2000");

            _interpreter.InitArgs(args.ToArray());

            _formatHandler.Initialize();

            _formatHandler.Open(_filePath);

            if (_showPageAfterOpen)
            {
                this.ShowPage(_formatHandler.FirstPageNumber, true);
            }
        }