protected virtual void AddReturn(PDFUnit widthOfLastTextDraw, bool hardReturn)
        {
            this.AssertCurrentLine();
            PDFLayoutLine     line = this.CurrentLine;
            PDFTextRunNewLine br   = new PDFTextRunNewLine(false, line, this.TextRenderOptions, this.TextComponent);


            line.AddRun(br);

            //The offset is from the start of the last text drawing operation
            //and the offset of the start of the current line
            PDFUnit lineright = widthOfLastTextDraw;

            PDFUnit back = line.Width - lineright;

            //Previous - 27 Feb 2015
            //br.Offset = new PDFSize(back, line.Height);

            //Updated
            if (line.BaseLineOffset == 0 || this.TextRenderOptions.Leading.HasValue) //we don't have any begins or ends affecting the flow (or an explicit leading)
            {
                br.Offset = new PDFSize(back, line.Height);
            }
            else
            {
                br.Offset = new PDFSize(back, (line.Height - line.BaseLineOffset) + this.TextRenderOptions.GetAscent());
            }


            PDFLayoutRegion reg = line.Region;

            reg.CloseCurrentItem();
            line = reg.BeginNewLine();
            this.BeginningRun.Lines.Add(line);

            PDFUnit inset;

            if (hardReturn)
            {
                inset = this.TextRenderOptions.GetFirstLineInset();
            }
            else
            {
                inset = PDFUnit.Zero;
            }

            PDFTextRunSpacer spacer = this.AddLineInsetRun(inset, 0, line);

            br.NextLineSpacer     = spacer;
            this.CurrentLine      = line;
            this.CurrentLineInset = inset;
        }
Exemple #2
0
        private PDFLayoutInlineEnd CreateAndAddInlineEnd(PDFPositionOptions pos, PDFLayoutInlineBegin begin)
        {
            PDFLayoutBlock  containerBlock  = this.DocumentLayout.CurrentPage.LastOpenBlock();
            PDFLayoutRegion containerRegion = containerBlock.CurrentRegion;

            if (containerRegion.HasOpenItem == false)
            {
                containerRegion.BeginNewLine();
            }
            PDFLayoutLine      currline = containerRegion.CurrentItem as PDFLayoutLine;
            PDFLayoutInlineEnd end      = currline.AddInlineRunEnd(this, this.Component, begin, pos);

            return(end);
        }
Exemple #3
0
        private PDFLayoutInlineBegin CreateAndAddInlineBegin(PDFPositionOptions pos)
        {
            PDFLayoutBlock  containerBlock  = this.DocumentLayout.CurrentPage.LastOpenBlock();
            PDFLayoutRegion containerRegion = containerBlock.CurrentRegion;

            if (containerRegion.HasOpenItem == false)
            {
                containerRegion.BeginNewLine();
            }
            PDFLayoutLine        currline = containerRegion.CurrentItem as PDFLayoutLine;
            PDFLayoutInlineBegin begin    = currline.AddInlineRunStart(this, this.Component, pos, this.FullStyle);

            return(begin);
        }
Exemple #4
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);
        }
        /// <summary>
        /// If there is no open line at the start, or after a hard return, then this created a new one (adding inset as required)
        /// </summary>
        /// <returns></returns>
        private PDFLayoutLine EnsureFirstLineAvailable(out bool startedLine)
        {
            startedLine = false;
            PDFLayoutPage  pg    = this.Context.DocumentLayout.CurrentPage;
            PDFLayoutBlock block = pg.LastOpenBlock();

            if (null == block || block.IsClosed)
            {
                this.Context.TraceLog.Add(TraceLevel.Error, LOG_CATEGORY, "There is no open block on page '" + pg.ToString() + "' to add content to.");
                return(null);

                throw new InvalidOperationException("There is no open block to add the textual content to.");
            }
            PDFLayoutRegion reg = block.CurrentRegion;

            if (null == reg || reg.IsClosed)
            {
                this.Context.TraceLog.Add(TraceLevel.Error, LOG_CATEGORY, "There is no open region in block '" + block.ToString() + "' on page '" + pg.ToString() + "' to add content to.");
                return(null);

                throw new InvalidOperationException("There is no open block to add the textual content to.");
            }
            PDFLayoutLine line;

            if (reg.HasOpenItem)
            {
                line = (PDFLayoutLine)reg.CurrentItem;
            }
            else
            {
                line        = reg.BeginNewLine();
                startedLine = true;
                //No Inset spacer as this will be handled by the begin run
            }

            return(line);
        }