示例#1
0
        public ContentStreamProcessor(PdfRectangle cropBox, IResourceStore resourceStore, UserSpaceUnit userSpaceUnit, PageRotationDegrees rotation,
                                      IPdfTokenScanner pdfScanner,
                                      IPageContentParser pageContentParser,
                                      IFilterProvider filterProvider,
                                      ILog log,
                                      bool clipPaths)
        {
            this.resourceStore     = resourceStore;
            this.userSpaceUnit     = userSpaceUnit;
            this.rotation          = rotation;
            this.pdfScanner        = pdfScanner ?? throw new ArgumentNullException(nameof(pdfScanner));
            this.pageContentParser = pageContentParser ?? throw new ArgumentNullException(nameof(pageContentParser));
            this.filterProvider    = filterProvider ?? throw new ArgumentNullException(nameof(filterProvider));
            this.log       = log;
            this.clipPaths = clipPaths;

            // initiate CurrentClippingPath to cropBox
            var clippingSubpath = new PdfSubpath();

            clippingSubpath.Rectangle(cropBox.BottomLeft.X, cropBox.BottomLeft.Y, cropBox.Width, cropBox.Height);
            var clippingPath = new PdfPath()
            {
                clippingSubpath
            };

            clippingPath.SetClipping(FillingRule.NonZeroWinding);

            graphicsStack.Push(new CurrentGraphicsState()
            {
                CurrentClippingPath = clippingPath
            });
            ColorSpaceContext = new ColorSpaceContext(GetCurrentState, resourceStore);
        }
示例#2
0
文件: PdfPath.cs 项目: xtuzy/PdfPig
        /// <summary>
        /// Create a clone with no Subpaths.
        /// </summary>
        internal PdfPath CloneEmpty()
        {
            PdfPath newPath = new PdfPath();

            if (IsClipping)
            {
                newPath.SetClipping(FillingRule);
            }
            else
            {
                if (IsFilled)
                {
                    newPath.SetFilled(FillingRule);
                    newPath.FillColor = FillColor;
                }

                if (IsStroked)
                {
                    newPath.SetStroked();
                    newPath.LineCapStyle    = LineCapStyle;
                    newPath.LineDashPattern = LineDashPattern;
                    newPath.LineJoinStyle   = LineJoinStyle;
                    newPath.LineWidth       = LineWidth;
                    newPath.StrokeColor     = StrokeColor;
                }
            }
            return(newPath);
        }