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
        protected virtual PDFLayoutBlock CreateContinerBlock(PDFPositionOptions position)
        {
            bool            newPage         = false;
            PDFLayoutBlock  containerBlock  = this.DocumentLayout.CurrentPage.LastOpenBlock();
            PDFLayoutRegion containerRegion = containerBlock.CurrentRegion;

            if (containerRegion.HasOpenItem)
            {
                containerRegion.CloseCurrentItem();
            }

            PDFUnit required = PDFUnit.Zero;

            if (position.Height.HasValue)
            {
                required = position.Height.Value;
            }
            //ADDED for min/max sizes.
            else if (position.MinimumHeight.HasValue)
            {
                required = position.MinimumHeight.Value;
            }

            //Do we have space
            if (containerRegion.AvailableHeight <= 0 || (containerRegion.AvailableHeight < required))
            {
                if (this.MoveToNextRegion(required, ref containerRegion, ref containerBlock, out newPage) == false)
                {
                    this.Context.TraceLog.Add(TraceLevel.Warning, LOG_CATEGORY, "Cannot fit the block for component " + this.Component.UniqueID + " in the avilable height (required = '" + position.Height + "', available = '" + containerRegion.AvailableHeight + "'), and we cannot overflow to a new region. Layout of component stopped and returning.");
                    this.ContinueLayout = false;
                    return(null);
                }
            }

            CurrentBlock = containerBlock.BeginNewContainerBlock(this.Component, this, this.FullStyle, position.PositionMode);
            CurrentBlock.BlockRepeatIndex = 0;
            return(containerBlock);
        }