protected override void DoLayoutChildren()
        {
            PDFPositionOptions position = this.FullStyle.CreatePostionOptions();
            PDFLayoutXObject   canvas   = null;

            if (position.ViewPort.HasValue)
            {
                canvas = this.ApplyViewPort(position, position.ViewPort.Value);
            }

            base.DoLayoutChildren();

            if (null != canvas)
            {
                canvas.Close();

                this.CloseCurrentLine();

                canvas.OutPutName = (PDFName)this.Context.Document.GetIncrementID(PDFObjectTypes.CanvasXObject);
                var rsrc  = new PDFCanvasResource(this.Component as Canvas, canvas, position.ViewPort.Value);
                var ratio = this.FullStyle.GetValue(SVGAspectRatio.AspectRatioStyleKey, SVGAspectRatio.Default);

                var size = new PDFSize(canvas.Width, canvas.Height);
                canvas.Matrix   = CalculateMatrix(size, position.ViewPort.Value, ratio);
                canvas.ClipRect = new PDFRect(position.X.HasValue ? position.X.Value : PDFUnit.Zero,
                                              position.Y.HasValue ? position.Y.Value : PDFUnit.Zero,
                                              canvas.Width, canvas.Height);
                this.Context.DocumentLayout.CurrentPage.PageOwner.Register(rsrc);
                this.Context.Document.EnsureResource(rsrc.ResourceType, rsrc.ResourceKey, rsrc);
            }
        }
示例#2
0
        public PDFLayoutXObject AddXObjectRun(IPDFLayoutEngine engine, IPDFComponent component, PDFLayoutRegion container, PDFPositionOptions options, Style full)
        {
            PDFLayoutXObject xobject = new PDFLayoutXObject(this, container, options, component);

            this.Runs.Add(xobject);
            return(xobject);
        }
 public PDFCanvasResource(Canvas component, PDFLayoutXObject layout, PDFRect viewPort)
     : base(PDFObjectTypes.CanvasXObject)
 {
     this._layout    = layout;
     this._component = component;
     this.Name       = layout.OutPutName;
 }
示例#4
0
 public void SetAppearance(FormFieldAppearanceState state, Layout.PDFLayoutXObject xObject, Layout.PDFLayoutPage page, Styles.Style style)
 {
     this._states[state] = xObject;
     if (state == FormFieldAppearanceState.Normal)
     {
         this._style = style;
     }
     this._page = page;
 }
示例#5
0
        private PDFLayoutXObject CreateAndAddInput(PDFPositionOptions pos)
        {
            PDFLayoutBlock  containerBlock  = this.DocumentLayout.CurrentPage.LastOpenBlock();
            PDFLayoutRegion containerRegion = containerBlock.CurrentRegion;

            if (containerRegion.HasOpenItem == false)
            {
                containerRegion.BeginNewLine();
            }
            //pos.Y = 200;
            PDFLayoutRegion container = containerBlock.BeginNewPositionedRegion(pos, this.DocumentLayout.CurrentPage, this.Component, this.FullStyle, false);

            this.Line = containerRegion.CurrentItem as PDFLayoutLine;
            PDFLayoutXObject begin = this.Line.AddXObjectRun(this, this.Field, container, pos, this.FullStyle);

            return(begin);
        }
        protected virtual PDFLayoutXObject ApplyViewPort(PDFPositionOptions oldpos, PDFRect viewPort)
        {
            //Set the size to the viewport size
            var newpos = oldpos.Clone();

            newpos.X = viewPort.X;
            newpos.Y = viewPort.Y;

            //update to new widths
            newpos.Width  = viewPort.Width;
            newpos.Height = viewPort.Height;

            //Set the style values to the viewport too. (and reset the cache)

            this.FullStyle.Size.Width  = newpos.Width.Value;
            this.FullStyle.Size.Height = newpos.Height.Value;

            if (this.FullStyle is Scryber.Styles.StyleFull)
            {
                (this.FullStyle as StyleFull).ClearFullRefs();
            }

            PDFLayoutBlock  containerBlock  = this.DocumentLayout.CurrentPage.LastOpenBlock();
            PDFLayoutRegion containerRegion = containerBlock.CurrentRegion;

            if (containerRegion.HasOpenItem == false)
            {
                containerRegion.BeginNewLine();
            }
            //pos.Y = 200;
            PDFLayoutRegion container = containerBlock.BeginNewPositionedRegion(newpos, this.DocumentLayout.CurrentPage, this.Component, this.FullStyle, false);

            this.Line = containerRegion.CurrentItem as PDFLayoutLine;



            PDFLayoutXObject begin = this.Line.AddXObjectRun(this, this.Component, container, newpos, this.FullStyle);

            begin.SetOutputSize(oldpos.Width, oldpos.Height);


            //this.CurrentBlock.IsFormXObject = true;
            //this.CurrentBlock.XObjectViewPort = pos.ViewPort.Value;

            return(begin);
        }
示例#7
0
        protected override void DoLayoutComponent()
        {
            PDFPositionOptions pos = this.FullStyle.CreatePostionOptions();

            PDFLayoutXObject xObject = this.CreateAndAddInput(pos);

            _addedProxyText = false;

            if (string.IsNullOrEmpty(this.Field.Value))
            {
                this.Field.Value = "Proxy Text";
                _addedProxyText  = true;
            }

            base.DoLayoutComponent();



            xObject.Close();

            if (pos.PositionMode == Drawing.PositionMode.Block)
            {
                this.CloseCurrentLine();
            }

            this.LayoutPage = this.Context.DocumentLayout.CurrentPage;
            IArtefactCollection annots;

            if (!this.LayoutPage.Artefacts.TryGetCollection(PDFArtefactTypes.Annotations, out annots))
            {
                annots = new PDFAnnotationCollection(PDFArtefactTypes.Annotations);
                this.LayoutPage.Artefacts.Add(annots);
            }


            this.LayoutPage = this.Context.DocumentLayout.CurrentPage;

            annots.Register(this.Field.Widget);
            this.Field.Widget.SetAppearance(FormFieldAppearanceState.Normal, xObject, this.LayoutPage, this.FullStyle);
            this.Field.Widget.SetAppearance(FormFieldAppearanceState.Down, xObject, this.LayoutPage, this.FullStyle);
            this.Field.Widget.SetAppearance(FormFieldAppearanceState.Over, xObject, this.LayoutPage, this.FullStyle);
        }