/// <summary> /// Looks for the component with the specified name or ID and sets instance variables appropriately /// </summary> /// <param name="context"></param> /// <param name="name"></param> private Component LookupExternalComponent(bool rendering, PDFLayoutContext context, string name) { Component comp; if (name.StartsWith(Const.ComponentIDPrefix)) { name = name.Substring(Const.ComponentIDPrefix.Length); comp = this.Document.FindAComponentById(name); } else { comp = Document.FindAComponentByName(name); } if (null == comp && string.IsNullOrEmpty(this.NotFoundText)) { if (!rendering) { //don't need it just yet } if (context.Conformance == ParserConformanceMode.Strict) { throw new PDFException(string.Format(Errors.CouldNotFindControlWithID, name)); } else { context.TraceLog.Add(TraceLevel.Error, "Page Locator", string.Format(Errors.CouldNotFindControlWithID, this.ComponentName)); } } return(comp); }
// // methods // #region protected override Text.PDFTextReader CreateReader(PDFLayoutContext context, Styles.PDFStyle fullstyle) /// <summary> /// overrides the default implementation to create a text reader for the Number in the correct format /// </summary> /// <param name="context"></param> /// <param name="fullstyle"></param> /// <returns></returns> protected override Text.PDFTextReader CreateReader(PDFLayoutContext context, Styles.Style fullstyle) { string val; string format = fullstyle.GetValue(StyleKeys.TextNumberFormatKey, string.Empty); if (null == this.FormatProvider) { if (!string.IsNullOrEmpty(format)) { val = this.Value.ToString(format); } else { val = this.Value.ToString(); } } else { if (!string.IsNullOrEmpty(format)) { val = this.Value.ToString(format, this.FormatProvider); } else { val = this.Value.ToString(this.FormatProvider); } } return(Scryber.Text.PDFTextReader.Create(val, TextFormat.Plain, false, context.TraceLog)); }
public void Layout(PDFLayoutContext context, Styles.Style fullstyle) { bool first = true; PDFPageNumberOptions opts = fullstyle.CreatePageNumberOptions(); PDFPageNumberGroup grp = null; if (null != opts && opts.HasPageNumbering) { grp = context.DocumentLayout.Numbers.PushPageNumber(opts); } foreach (PageBase pg in this._group.Pages) { if (pg.Visible) { this.LayoutAPage(pg, first); first = false; } if (!this.ContinueLayout) { break; } } if (null != opts && opts.HasPageNumbering) { context.DocumentLayout.Numbers.PopNumberStyle(grp); } }
protected override void OnPreLayout(PDFLayoutContext context) { this.Contents.Clear(); string val = this.Value; if (!string.IsNullOrEmpty(val)) { if (!string.IsNullOrEmpty(this.Format)) { double d; DateTime dt; if (double.TryParse(val, out d)) { val = d.ToString(this.Format); } else if (DateTime.TryParse(val, out dt)) { val = dt.ToString(this.Format); } } } this.Contents.Add(new TextLiteral(val)); base.OnPreLayout(context); }
/// <summary> /// Registers all the artefacts (name, outline) for this component (and only this component). Artefacts can represent /// </summary> /// <param name="context"></param> /// <param name="fullstyle"></param> /// <returns></returns> public virtual PDFArtefactRegistrationSet RegisterLayoutArtefacts(PDFLayoutContext context, Style fullstyle) { PDFArtefactRegistrationSet set = new PDFArtefactRegistrationSet(context.DocumentLayout, this); bool registername = this.ShouldRegisterName(context); bool registerOutline = this.ShouldRegisterOutline(context); if (registername || registerOutline) { //register the name object name = context.DocumentLayout.RegisterCatalogEntry(context, PDFArtefactTypes.Names, new PDFDestination(this, OutlineFit.FullPage)); set.SetArtefact(PDFArtefactTypes.Names, name); } object outline = null; //if we have a title then register the outline component if (registerOutline) { outline = context.DocumentLayout.RegisterCatalogEntry(context, PDFArtefactTypes.Outlines, new PDFOutlineRef(this.Outline, fullstyle.Outline)); set.SetArtefact(PDFArtefactTypes.Outlines, outline); } this.DoRegisterArtefacts(context, set, fullstyle); return(set); }
protected override void OnPreLayout(PDFLayoutContext context) { this.Contents.Clear(); this.Contents.Add(new TextLiteral(this.Text)); base.OnPreLayout(context); }
private void FillActionAnnotations(PDFLayoutContext context, Styles.Style style, PDFAction action, List <object> entries, Layout.PDFLayoutPage pg, ComponentList contents) { foreach (Component comp in contents) { PDFAnnotationLinkEntry annot; ComponentList inner; if (IsContainer(comp, out inner)) { FillActionAnnotations(context, style, action, entries, pg, inner); } else { //TODO: Test with data source within link annot = new PDFAnnotationLinkEntry(comp, style); annot.Action = action; if (!string.IsNullOrEmpty(this.AlternateText)) { annot.AlternateText = this.AlternateText; } object entry = pg.RegisterPageEntry(context, PDFArtefactTypes.Annotations, annot); if (null != entry) { entries.Add(entry); } } } }
protected override void DoRegisterArtefacts(PDFLayoutContext context, PDFArtefactRegistrationSet set, Style fullstyle) { base.DoRegisterArtefacts(context, set, fullstyle); //object entry = context.DocumentLayout.RegisterCatalogEntry(context, PDFArtefactTypes.AcrobatForms, new PDFAcrobatFormEntry(this.ID)); //this.FormEntry = (PDFAcrobatFormEntry)entry; }
protected override void DoCloseLayoutArtefacts(PDFLayoutContext context, PDFArtefactRegistrationSet artefacts, Styles.Style fullstyle) { base.DoCloseLayoutArtefacts(context, artefacts, fullstyle); //Close the inner chid annotation entries object entries; if (artefacts.TryGetArtefact(LinkAnnotationChildEntries, out entries)) { object[] all = (object[])entries; //TODO: Check the use of a link that flows over more than one page Layout.PDFLayoutPage pg = context.DocumentLayout.CurrentPage; for (int i = all.Length - 1; i >= 0; i--) { pg.CloseArtefactEntry(PDFArtefactTypes.Annotations, all[i]); } } //Close the actual link object link; if (artefacts.TryGetArtefact(LinkArtefactName, out link)) { context.DocumentLayout.CloseArtefactEntry(PDFArtefactTypes.Names, link); } }
protected override void OnPreLayout(PDFLayoutContext context) { bool performload = true; this.EnsureContentsParsed(context, performload); base.OnPreLayout(context); }
// // implementation // protected override void DoPushComponentLayout(PDFLayoutContext context, int pageIndex, PDFUnit xoffset, PDFUnit yoffset) { base.DoPushComponentLayout(context, pageIndex, xoffset, yoffset); //As we have now completed the full layout of this begin -> end text block, then we can close it off. this.Start.PushCompleteTextBlock(this, context, pageIndex, xoffset, yoffset); }
protected override void DoPushComponentLayout(PDFLayoutContext context, int pageIndex, PDFUnit xoffset, PDFUnit yoffset) { if (xoffset > 0) { this._w += xoffset; } base.DoPushComponentLayout(context, pageIndex, xoffset, yoffset); }
private object[] AddActionAnnotationToChildren(PDFLayoutContext context, Styles.Style style, PDFAction action) { List <object> entries = new List <object>(); Layout.PDFLayoutPage pg = context.DocumentLayout.CurrentPage; FillActionAnnotations(context, style, action, entries, pg, this.Contents); return(entries.ToArray()); }
public bool RegisterField(IPDFFormField field, PDFLayoutContext context) { if (null == this.FormEntry) { throw new PDFLayoutException("This forms artefact has not been registered"); } return(this.FormEntry.RegisterField(field, context)); }
protected override void OnPreLayout(PDFLayoutContext context) { if (!string.IsNullOrEmpty(this.Text)) { this.Contents.Clear(); this.Contents.Add(new TextLiteral(this.Text)); } base.OnPreLayout(context); }
protected override void OnPreLayout(PDFLayoutContext context) { var bounds = this.GetBounds(); this.X = bounds.X; this.Y = bounds.Y; this.Width = bounds.Width; this.Height = bounds.Height; base.OnPreLayout(context); }
public void RegisterPreLayout(PDFLayoutContext context) { foreach (IPDFComponent com in this) { if (com is Component) { ((Component)com).RegisterPreLayout(context); } } }
public void RegisterLayoutComplete(PDFLayoutContext context) { foreach (IPDFComponent comp in this) { if (comp is Component) { ((Component)comp).RegisterLayoutComplete(context); } } }
protected override void OnPreLayout(PDFLayoutContext context) { base.OnPreLayout(context); DoLoadReference(context); if (this.IsContentLoaded) { this.InnerContent.AddContent(this.Document, context); } }
protected override void DoRegisterArtefacts(PDFLayoutContext context, PDFArtefactRegistrationSet set, Style fullstyle) { //var form = this.GetParentForm(context); PDFAcrobatFormFieldWidget entry = GetFieldEntry(context); context.DocumentLayout.RegisterCatalogEntry(context, PDFArtefactTypes.AcrobatForms, entry); this.Widget = entry; base.DoRegisterArtefacts(context, set, fullstyle); }
/// <summary> /// Overrides the default behaviour to enumerate over the line contents /// </summary> /// <param name="context"></param> protected override void DoPushComponentLayout(PDFLayoutContext context, int pageindex, PDFUnit xoffset, PDFUnit yoffset) { bool logdebug = context.ShouldLogDebug; if (logdebug) { context.TraceLog.Begin(TraceLevel.Debug, "Layout Line", "Pushing component layout onto runs in the line " + this.ToString()); } //There is a special case where the rendering relies on the previous line height of a text block //To offset the next line. //This works fune unless it is not TOP aligned and there is //something else increasing the height of the line. //Where we apply an offset to the block so that it sits //at the bottom of the line itself. //This pushes the next line down. //So we need the first line of a text block to be handled differently bool isspecial = this.IsSpecialTextAlignmentCase(); foreach (PDFLayoutRun run in this.Runs) { PDFUnit itemYOffset = yoffset; if (isspecial) { } else if (this.VAlignment != VerticalAlignment.Top) { PDFUnit used = run.Height; PDFUnit avail = this.Height; PDFUnit space = avail - used; if (this.VAlignment == VerticalAlignment.Middle) { space = space / 2; } itemYOffset += space; } run.PushComponentLayout(context, pageindex, xoffset, itemYOffset); } if (logdebug) { context.TraceLog.End(TraceLevel.Debug, "Layout Line", "Pushed all the component layouts onto the runs in the line " + this.ToString()); } }
/// <summary> /// Raises the LayoutComplete event /// </summary> /// <param name="context"></param> protected virtual void OnLayoutComplete(PDFLayoutContext context) { if (this.HasRegisteredEvents) { PDFLayoutEventHandler handler = (PDFLayoutEventHandler)this.Events[PostLayoutEventKey]; if (null != handler) { handler(this, new PDFLayoutEventArgs(context)); } } }
protected override void OnPreLayout(PDFLayoutContext context) { PDFRect rect = GetBounds(); this.X = rect.X; this.Y = rect.Y; this.Width = rect.Width; this.Height = rect.Height; base.OnPreLayout(context); }
public object RegisterPageEntry(PDFLayoutContext context, string artefactType, IArtefactEntry entry) { IArtefactCollection col; if (!Artefacts.TryGetCollection(artefactType, out col)) { col = context.DocumentLayout.CreateArtefactCollection(artefactType); _artefacts.Add(col); } return(col.Register(entry)); }
/// <summary> /// Overrides base implementation to call the inner content methods /// </summary> internal override void RegisterLayoutComplete(PDFLayoutContext context) { base.RegisterLayoutComplete(context); if (this.HasContent) { for (int i = 0; i < this.InnerContent.Count; i++) { Component comp = this.InnerContent[i]; comp.RegisterLayoutComplete(context); } } }
protected virtual PDFTextReader CreateReader(PDFLayoutContext context, Style fullstyle) { TextFormat format = TextFormat.Plain; bool preserveWhitespace = fullstyle.GetValue(StyleKeys.TextWhitespaceKey, false); if (this is IPDFTextLiteral) { format = ((IPDFTextLiteral)this).ReaderFormat; } return(PDFTextReader.Create(this.BaseText, format, preserveWhitespace, context.TraceLog)); }
public LayoutEnginePageGroup(PageGroup group, IPDFLayoutEngine parent, PDFLayoutContext context, Style full) { if (null == group) { throw new ArgumentNullException("group"); } this._group = group; this._parent = parent; this._context = context; this._full = full; this.ContinueLayout = true; }
protected override void DoRegisterArtefacts(PDFLayoutContext context, PDFArtefactRegistrationSet set, Style fullstyle) { _orgitems = context.Items; if (this.HasParams) { PDFItemCollection updated = _orgitems.Clone(); updated.Merge(this.Params); context.Items = updated; } base.DoRegisterArtefacts(context, set, fullstyle); }
/// <summary> /// Overrides the move to the next region - not complete /// </summary> /// <returns></returns> public override bool MoveToNextRegion(PDFUnit requiredHeight, PDFLayoutContext context) { if (this.ContentBlock.Position.OverflowAction == OverflowAction.NewPage) { PDFLayoutPage cont = this.Document.BeginNewContinuationPage(); cont.InitPage(this.Size, this.ContentBlock.Position, this.ContentBlock.ColumnOptions, context); return(cont != null); } else { return(false); } }
public bool AssertIncrement(PDFLayoutContext context) { this._count++; if (this._count > ZeroCharactersPerThreshold) { context.TraceLog.Add(TraceLevel.Error, "Text Layout", "Fell into a suspected never ending loop of laying out zero characters per line. Breaking out ungracefully"); return(false); } else { return(true); } }