public virtual void EventOccurred(IEventData iEventData, EventType eventType)
        {
            if (eventType == EventType.RENDER_PATH)
            {
                PathRenderInfo pathInfo      = (PathRenderInfo)iEventData;
                Color          colorFill     = iEventData.GetGraphicsState().GetFillColor();
                Color          colorStroke   = iEventData.GetGraphicsState().GetStrokeColor();
                int            pathOperation = pathInfo.GetOperation();

                if (!pathInfo.IsPathModifiesClippingPath() && pathOperation != PathRenderInfo.NO_OP)
                {
                    if (pathOperation == PathRenderInfo.STROKE)
                    {
                        if (!Color.IsWhite(colorStroke.GetColorSpace(), colorStroke.GetColorValue()))
                        {
                            Path path = pathInfo.GetPath().TransformPath(pathInfo.GetCtm(), false);
                            ProcessPathAsline(path, pathInfo.GetLineWidth());
                        }
                    }
                    else if (pathOperation == PathRenderInfo.FILL)
                    {
                        if (!Color.IsWhite(colorFill.GetColorSpace(), colorFill.GetColorValue()))
                        {
                            Path path = pathInfo.GetPath().TransformPath(pathInfo.GetCtm(), false);
                            ProcessPathAsRectangle(path);
                        }
                    }
                    else if (pathOperation == (int)(PathRenderInfo.STROKE | PathRenderInfo.FILL))
                    {
                        if (!Color.IsWhite(colorFill.GetColorSpace(), colorFill.GetColorValue()))
                        {
                            Path path = pathInfo.GetPath().TransformPath(pathInfo.GetCtm(), false);
                            ProcessPathAsRectangle(path);
                        }
                        else if (!Color.IsWhite(colorStroke.GetColorSpace(), colorStroke.GetColorValue()) &&
                                 Color.IsWhite(colorFill.GetColorSpace(), colorFill.GetColorValue()))
                        {
                            Path path = pathInfo.GetPath().TransformPath(pathInfo.GetCtm(), false);
                            ProcessPathAsline(path, pathInfo.GetLineWidth());
                        }
                    }
                }
            }
            else if (eventType == EventType.RENDER_TEXT)
            {
                if (iEventData is AbstractRenderInfo)
                {
                    ((AbstractRenderInfo)iEventData).PreserveGraphicsState();
                    textRenderList.Add(iEventData);
                }
            }
        }
Пример #2
0
        /// <summary>Filter a PathRenderInfo object</summary>
        /// <param name="path">the PathRenderInfo object to be filtered</param>
        public virtual Path FilterStrokePath(PathRenderInfo path)
        {
            PdfArray        dashPattern     = path.GetLineDashPattern();
            LineDashPattern lineDashPattern = new LineDashPattern(dashPattern.GetAsArray(0), dashPattern.GetAsNumber(1
                                                                                                                     ).FloatValue());

            return(FilterStrokePath(path.GetPath(), path.GetCtm(), path.GetLineWidth(), path.GetLineCapStyle(), path.GetLineJoinStyle
                                        (), path.GetMiterLimit(), lineDashPattern));
        }
Пример #3
0
        public virtual void ParsePath(PathRenderInfo data)
        {
            var shapeOperation = (ShapeOperation)data.GetOperation();

            if (shapeOperation == ShapeOperation.None)
            {
                return;
            }
            bool evenOddRule = data.GetRule() == PdfCanvasConstants.FillingRule.EVEN_ODD;
            var  fillColor   = ColorManager.Instance.GetColor(data.GetFillColor(), data.GetGraphicsState().GetFillOpacity());

            if (shapeOperation != ShapeOperation.Stroke && (fillColor == null || fillColor == Color.Black))
            {
                return;
            }

            var strokeColor = ColorManager.Instance.GetColor(data.GetStrokeColor(), data.GetGraphicsState().GetStrokeOpacity());
            var lineWidth   = data.GetLineWidth();
            var lineCap     = data.GetLineCapStyle();
            var ctm         = data.GetCtm();
            var lines       = ConvertLines(data.GetPath(), ctm).ToArray();

            if (lines.Length == 0)
            {
                return;
            }


            var shapeDetails = new ShapeDetails
            {
                ShapeOperation = shapeOperation,
                StrokeColor    = strokeColor,
                FillColor      = fillColor,
                LineWidth      = lineWidth,
                EvenOddRule    = evenOddRule,
                Lines          = lines
            };

            if (Log.DebugSupported)
            {
                Log.Debug($"shape: {shapeDetails}");
            }
            shapes.Add(shapeDetails);
        }