Ejemplo n.º 1
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.Tlm.Multiply(new Matrix(1, 0, 0, 1, 0, (float)-state.Lead));
     state.Tm = state.Tlm.Clone();
 }
Ejemplo n.º 2
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.FillColorSpace = DeviceGrayColorSpace.Default;
     base.Scan(state);
 }
Ejemplo n.º 3
0
        /**
         * <summary>Begins a content row.</summary>
         */
        private void BeginRow(
            )
        {
            rowEnded = false;

            ContentScanner.GraphicsState state = baseComposer.State;

            double rowY = boundBox.Height;

            if (rowY > 0)
            {
                rowY += lineSpace.GetValue(state.Font != null ? state.Font.GetLineHeight(state.FontSize) : 0);
            }
            currentRow = new Row(rowY);
            if (xAlignment == XAlignmentEnum.Justify)
            {
                /*
                 * TODO: This temporary hack forces PrimitiveComposer.showText() to insert word space
                 * adjustments in case of justified text; when the row ends, it has to be updated with the
                 * actual adjustment value.
                 */
                currentRow.WordSpaceAdjustment = baseComposer.Add(new SetWordSpace(.001));
            }
            else if (state.WordSpace != 0)
            {
                baseComposer.SetWordSpace(0);
            }
        }
Ejemplo n.º 4
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.Font     = state.Scanner.ContentContext.Resources.Fonts[Name];
     state.FontSize = Size;
 }
Ejemplo n.º 5
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.Tlm = Value;
     state.Tm  = state.Tlm.Clone();
 }
Ejemplo n.º 6
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.StrokeColorSpace = DeviceCMYKColorSpace.Default;
     base.Scan(state);
 }
Ejemplo n.º 7
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            ContentScanner scanner    = state.Scanner;
            GraphicsPath   pathObject = scanner.RenderObject;

            if (pathObject != null)
            {
                Graphics context = scanner.RenderContext;

                if (closed)
                {
                    pathObject.CloseFigure();
                }
                if (filled)
                {
                    pathObject.FillMode = fillMode.ToGdi();
                    context.FillPath(state.FillColorSpace.GetPaint(state.FillColor), pathObject);
                }
                if (stroked)
                {
                    context.DrawPath(GetStroke(state), pathObject);
                }
            }
        }
Ejemplo n.º 8
0
        private static Pen GetStroke(
            ContentScanner.GraphicsState state
            )
        {
            Pen stroke = new Pen(
                state.StrokeColorSpace.GetPaint(state.StrokeColor),
                (float)state.LineWidth
                );

            {
                LineCap lineCap = state.LineCap.ToGdi();
                stroke.SetLineCap(lineCap, lineCap, lineCap.ToDashCap());
                stroke.LineJoin   = state.LineJoin.ToGdi();
                stroke.MiterLimit = (float)state.MiterLimit;

                LineDash lineDash  = state.LineDash;
                double[] dashArray = lineDash.DashArray;
                if (dashArray.Length > 0)
                {
                    stroke.DashPattern = ConvertUtils.ToFloatArray(dashArray);
                    stroke.DashOffset  = (float)lineDash.DashPhase;
                }
            }
            return(stroke);
        }
Ejemplo n.º 9
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.Font     = GetFont(state.Scanner.ContentContext);
     state.FontSize = Size;
 }
Ejemplo n.º 10
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.Tlm.Translate(0, (float)state.Lead);
     state.Tm = state.Tlm.Clone();
 }
Ejemplo n.º 11
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            ExtGState extGState = GetExtGState(state.Scanner.ContentContext);

            extGState.ApplyTo(state);
        }
Ejemplo n.º 12
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            ExtGState extGState = state.Scanner.ContentContext.Resources.ExtGStates[Name];

            extGState.ApplyTo(state);
        }
Ejemplo n.º 13
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.FillColor = state.FillColorSpace.GetColor(
         operands,
         state.Scanner.ContentContext
         );
 }
Ejemplo n.º 14
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            ContentScanner childLevel = state.Scanner.ChildLevel;

              if(!Render(state))
              {childLevel.MoveEnd();} // Forces the current object to its final graphics state.

              childLevel.State.CopyTo(state); // Copies the current object's final graphics state to the current level's.
        }
Ejemplo n.º 15
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.Tlm.Translate((float)OffsetX, (float)OffsetY);
     state.Tm = state.Tlm.Clone();
     if (LeadSet)
     {
         state.Lead = OffsetY;
     }
 }
Ejemplo n.º 16
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.Tlm.Multiply(new Matrix(1, 0, 0, 1, (float)OffsetX, (float)OffsetY));
     state.Tm = state.Tlm.Clone();
     if (LeadSet)
     {
         state.Lead = -OffsetY;
     }
 }
Ejemplo n.º 17
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            GraphicsPath pathObject = state.Scanner.RenderObject;

            if (pathObject != null)
            {
                pathObject.CloseFigure();
            }
        }
Ejemplo n.º 18
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            GraphicsPath pathObject = state.Scanner.RenderObject;

            if (pathObject != null)
            {
                PointF point = Point;
                pathObject.AddLine(pathObject.GetLastPoint(), point);
            }
        }
Ejemplo n.º 19
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            ContentScanner scanner    = state.Scanner;
            GraphicsPath   pathObject = scanner.RenderObject;

            if (pathObject != null)
            {
                pathObject.FillMode = clipMode.ToGdi();
                scanner.RenderContext.SetClip(pathObject, CombineMode.Intersect);
            }
        }
Ejemplo n.º 20
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            state.Ctm.Multiply(Value);

            Graphics context = state.Scanner.RenderContext;

            if (context != null)
            {
                context.Transform = state.Ctm;
            }
        }
Ejemplo n.º 21
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            // 1. Color space.
            state.FillColorSpace = GetColorSpace(state.Scanner.ContentContext);

            // 2. Initial color.

            /*
             * NOTE: The operation also sets the current nonstroking color
             * to its initial value, which depends on the color space [PDF:1.6:4.5.7].
             */
            state.FillColor = state.FillColorSpace.DefaultColor;
        }
Ejemplo n.º 22
0
        public static ModifyCTM GetResetCTM(
            ContentScanner.GraphicsState state
            )
        {
            Matrix inverseCtm = state.Ctm.Clone();

            inverseCtm.Invert();
            return(new ModifyCTM(
                       inverseCtm
// TODO: inverseCtm is a simplification which assumes an identity initial ctm!
//        SquareMatrix.get(state.Ctm).solve(
//          SquareMatrix.get(state.GetInitialCtm())
//          ).toTransform()
                       ));
        }
Ejemplo n.º 23
0
        /**
         * Begins a content row.
         */
        private void BeginRow(
            )
        {
            rowEnded = false;

            float rowY = boundBox.Height;

            if (rowY > 0)
            {
                ContentScanner.GraphicsState state = baseComposer.State;
                rowY += lineSpace.GetValue(state.Font.GetLineHeight(state.FontSize));
            }
            currentRow = new Row(
                (ContentPlaceholder)baseComposer.Add(new ContentPlaceholder()),
                rowY
                );
        }
Ejemplo n.º 24
0
        /**
          <summary>Renders this container.</summary>
          <param name="state">Graphics state.</param>
          <returns>Whether the rendering has been executed.</returns>
         */
        protected bool Render(
            ContentScanner.GraphicsState state
            )
        {
            ContentScanner scanner = state.Scanner;
              Graphics context = scanner.RenderContext;
              if(context == null)
            return false;

              // Render the inner elements!
              scanner.ChildLevel.Render(
            context,
            scanner.CanvasSize,
            CreateRenderObject()
            );
              return true;
        }
Ejemplo n.º 25
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            GraphicsPath pathObject = state.Scanner.RenderObject;

            if (pathObject != null)
            {
                float x      = X,
                      y      = Y,
                      width  = Width,
                      height = Height;
                pathObject.AddRectangle(
                    new RectangleF(x, y, width, height)
                    );
                pathObject.CloseFigure();
            }
        }
Ejemplo n.º 26
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            GraphicsPath pathObject = state.Scanner.RenderObject;

            if (pathObject != null)
            {
                PointF controlPoint1 = (Control1.HasValue ? Control1.Value : pathObject.GetLastPoint());
                PointF finalPoint    = Point;
                PointF controlPoint2 = (Control2.HasValue ? Control2.Value : finalPoint);
                pathObject.AddBezier(
                    pathObject.GetLastPoint(),
                    controlPoint1,
                    controlPoint2,
                    finalPoint
                    );
            }
        }
Ejemplo n.º 27
0
        private static Pen GetStroke(
            ContentScanner.GraphicsState state
            )
        {
            Pen stroke = new Pen(
                state.StrokeColorSpace.GetPaint(state.StrokeColor),
                state.LineWidth
                );

            {
                LineCap lineCap = state.LineCap.ToGdi();
                stroke.SetLineCap(lineCap, lineCap, lineCap.ToDashCap());
                stroke.LineJoin    = state.LineJoin.ToGdi();
                stroke.MiterLimit  = state.MiterLimit;
                stroke.DashPattern = state.LineDash.DashArray;
                stroke.DashOffset  = state.LineDash.DashPhase;
            }
            return(stroke);
        }
Ejemplo n.º 28
0
        public override void Scan(
            ContentScanner.GraphicsState state
            )
        {
            Graphics context = state.Scanner.RenderContext;

            if (context != null)
            {
                /*
                 * NOTE: Local graphics state is purposely isolated from surrounding graphics state,
                 * so no inner operation can alter its subsequent scanning.
                 */
                // Save outer graphics state!
                GraphicsState contextState = context.Save();

                Render(state);

                // Restore outer graphics state!
                context.Restore(contextState);
            }
        }
Ejemplo n.º 29
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.WordSpace = Value;
 }
Ejemplo n.º 30
0
 public override void Scan(
     ContentScanner.GraphicsState state
     )
 {
     state.LineDash = Value;
 }