InitPage() public abstract method

public abstract InitPage ( int pageNumber ) : void
pageNumber int
return void
示例#1
0
        public void ShowPage(int pageNumber, bool refresh)
        {
            if (!this.IsEverythingInitialized)
            {
                return;
            }

            if (refresh == false && pageNumber == this.CurrentPageNumber)
            {
                return;
            }

            _formatHandler.InitPage(pageNumber);

            this.Interpreter.Run(@"
                            %%BeginPageSetup 
                            %%%%BeginFeature: PageSize Custom 
                            <<");

            if (_formatHandler.IsMediaBoxSet)
            {
                this.Interpreter.Run(string.Format("/PageSize [{0} {1}]", _formatHandler.MediaBox.Width, _formatHandler.MediaBox.Height));
                this.Interpreter.Run(string.Format("/MediaBox [{0} {1} {2} {3}]", 0, 0, _formatHandler.MediaBox.Width, _formatHandler.MediaBox.Height));
            }

            this.Interpreter.Run(string.Format("/HWResolution [{0} {1}]", _zoom_xDpi, _zoom_yDpi));

            this.Interpreter.Run(@">> 
                           setpagedevice");

            this.Interpreter.Run(@"
                           %%EndFeature 
                           %%EndPageSetup");

            _formatHandler.ShowPage(pageNumber);
        }
示例#2
0
        public void ShowPage(int pageNumber, bool refresh)
        {
            if (!this.IsEverythingInitialized)
            {
                return;
            }

            if (refresh == false && pageNumber == this.CurrentPageNumber)
            {
                return;
            }

            _formatHandler.InitPage(pageNumber);


            this.Interpreter.Run(
                "%%BeginPageSetup\n" +
                "<<\n");

            this.Interpreter.Run(string.Format("/HWResolution [{0} {1}]\n", _zoom_xDpi, _zoom_yDpi));

            GhostscriptRectangle mediaBox    = _formatHandler.MediaBox;
            GhostscriptRectangle boundingBox = _formatHandler.BoundingBox;
            GhostscriptRectangle cropBox     = _formatHandler.CropBox;

            float pageWidth  = 0;
            float pageHeight = 0;

            if ((_formatHandler.GetType() == typeof(GhostscriptViewerEpsFormatHandler) && this.EPSClip && boundingBox != GhostscriptRectangle.Empty))
            {
                pageWidth  = boundingBox.urx - boundingBox.llx;
                pageHeight = boundingBox.ury - boundingBox.lly;
            }
            else
            {
                if (cropBox != GhostscriptRectangle.Empty)
                {
                    pageWidth  = cropBox.urx - cropBox.llx;
                    pageHeight = cropBox.ury - cropBox.lly;
                }
                else
                {
                    pageWidth  = mediaBox.urx - mediaBox.llx;
                    pageHeight = mediaBox.ury - mediaBox.lly;
                }
            }

            pageWidth  = Math.Abs(pageWidth);
            pageHeight = Math.Abs(pageHeight);

            if (pageWidth > 0 && pageHeight > 0)
            {
                this.Interpreter.Run(string.Format("/PageSize [{0} {1}]\n",
                                                   pageWidth.ToString("0.00", CultureInfo.InvariantCulture),
                                                   pageHeight.ToString("0.00", CultureInfo.InvariantCulture)));
            }

            if (cropBox != GhostscriptRectangle.Empty)
            {
                mediaBox = cropBox;
            }

            if (mediaBox == GhostscriptRectangle.Empty && boundingBox != GhostscriptRectangle.Empty)
            {
                mediaBox = boundingBox;
            }

            if (mediaBox != GhostscriptRectangle.Empty && _formatHandler.GetType() != typeof(GhostscriptViewerPsFormatHandler))
            {
                this.Interpreter.Run(string.Format("/PageOffset  [{0} {1}]\n",
                                                   (-mediaBox.llx).ToString("0.00", CultureInfo.InvariantCulture),
                                                   (-mediaBox.lly).ToString("0.00", CultureInfo.InvariantCulture)));
            }

            this.Interpreter.Run(string.Format("/GraphicsAlphaBits {0}\n", _graphicsAlphaBits));
            this.Interpreter.Run(string.Format("/TextAlphaBits {0}\n", _textAlphaBits));

            this.Interpreter.Run(string.Format("/Orientation {0}\n", (int)this.CurrentPageOrientation));

            this.Interpreter.Run(">> setpagedevice\n");

            this.Interpreter.Run(
                "%%EndPageSetup\n");

            _formatHandler.ShowPage(pageNumber);
        }