private void VisitPathSegList(SvgGraphicsElement graphicsElement, SvgPathSegList paths)
        {
            if (!ShouldDisplay(graphicsElement))
            {
                return;
            }

            PushTransformsMatrix(graphicsElement.Transform);
            {
                var pathsToDraw = paths
                                  .ConvertToAbsolute()
                                  .ConvertAllLinesAndCurvesToCubicCurves()
                                  .MultiplyByMatrix(CurrentMatrix);

                var svgToPdfPathConverter = new SvgPathSegToDynamicPdfPathsConverter(graphicsElement, null, 0, _spotColorOverride);
                pathsToDraw.ForEach(i => i.Accept(svgToPdfPathConverter));

                foreach (var path in svgToPdfPathConverter.Paths)
                {
                    path.Draw(_writer);
                    ClippingAreaPainted = true;
                }
            }
            PopTransformsMatrix(graphicsElement.Transform);
        }
Ejemplo n.º 2
0
        private PageElement VisitPathSegList(SvgGraphicsElement graphicsElement, SvgPathSegList paths)
        {
            if (!IsVisible(graphicsElement))
            {
                return(null);
            }

            var result = new Group();

            PushTransformsMatrix(graphicsElement.Transform);
            var innerMatrix = CurrentMatrix;

            var pathsToDraw = paths
                              .ConvertToAbsolute()
                              .ConvertAllLinesAndCurvesToCubicCurves()
                              .MultiplyByMatrix(CurrentMatrix);

            var fillOpacity           = Math.Max(0, Math.Min(1, graphicsElement.Style.FillOpacity));
            var strokeOpacity         = Math.Max(0, Math.Min(1, graphicsElement.Style.StrokeOpacity));
            var svgToPdfPathConverter = new SvgPathSegToDynamicPdfPathsConverter(graphicsElement, _pageViewport, _pageHeight, _spotColorOverride);

            bool IsPaintedPath(Path path) => path.FillColor != null || path.LineColor != null;

            if (Math.Abs(fillOpacity - 1) > float.Epsilon || Math.Abs(strokeOpacity - 1) > float.Epsilon)
            {
                var fillGroup = new TransparencyGroup(fillOpacity * _groupAlpha);
                svgToPdfPathConverter.SetStrokeStyle(null);
                pathsToDraw.ForEach(i => i.Accept(svgToPdfPathConverter));
                fillGroup.AddRange(svgToPdfPathConverter.Paths.Where(IsPaintedPath));

                svgToPdfPathConverter.Reset();
                svgToPdfPathConverter.SetFillStyle(null);
                svgToPdfPathConverter.SetStrokeStyle(graphicsElement);
                var strokeGroup = new TransparencyGroup(strokeOpacity * _groupAlpha);
                pathsToDraw.ForEach(i => i.Accept(svgToPdfPathConverter));
                strokeGroup.AddRange(svgToPdfPathConverter.Paths.Where(IsPaintedPath));

                result.Add(fillGroup);
                result.Add(strokeGroup);
            }
            else
            {
                pathsToDraw.ForEach(i => i.Accept(svgToPdfPathConverter));
                result.AddRange(svgToPdfPathConverter.Paths.Where(IsPaintedPath));
            }
            PopTransformsMatrix(graphicsElement.Transform);

            return(result.Count == 0 ? null : CheckAndApplyClipPath(graphicsElement, result, innerMatrix));
        }