public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { if (this.Fields.Count > 0) { PDFObjectRef parent = writer.BeginObject(); List <PDFObjectRef> children = new List <PDFObjectRef>(); foreach (var fld in this.Fields) { var child = fld.OutputToPDF(context, writer); if (null != child) { children.Add(child); } } writer.BeginDictionary(); writer.WriteDictionaryStringEntry("T", this.Name); writer.BeginDictionaryEntry("Kids"); writer.WriteArrayRefEntries(true, children.ToArray()); writer.EndDictionaryEntry(); writer.EndDictionary(); writer.EndObject(); return(parent); } return(null); }
public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { if (context.ShouldLogDebug) { context.TraceLog.Begin(TraceLevel.Verbose, "Annotation Collection", "Outputting the doument annotations to the writer"); } PDFObjectRef annot = writer.BeginObject(); List <PDFObjectRef> entries = new List <PDFObjectRef>(); //TODO:Render annotations foreach (PDFAnnotationEntry entry in this._annots) { PDFObjectRef oref = entry.OutputToPDF(context, writer); if (oref != null) { entries.Add(oref); } } writer.WriteArrayRefEntries(entries.ToArray()); writer.EndObject(); if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Verbose, "Annotation Collection", "Completed the output of " + entries.Count + " annotations on the writer"); } return(annot); }
protected override void WriteCatalogEntries(PDFRenderContext context, PDFWriter writer) { if (null != this.OriginalFile) { PDFObjectRef catalog = writer.LastObjectReference(); PDFObjectRef pageTree = this.OutputPageTree(context, writer); foreach (KeyValuePair <PDFName, IFileObject> item in this.ExistingCatalog) { if (item.Key.Value == "Pages") { //PDFObjectRef pages = this.OutputAllPages writer.BeginDictionaryEntry(item.Key); pageTree.WriteData(writer); writer.EndDictionaryEntry(); } else { writer.BeginDictionaryEntry(item.Key); item.Value.WriteData(writer); writer.EndDictionaryEntry(); } } } else { base.WriteCatalogEntries(context, writer); } }
public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { if (null == _refs) { _refs = this.DoOutputToPDF(context, writer); } return(_refs); }
/// <summary> /// Writes a single destination /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <param name="name"></param> /// <returns></returns> internal bool WriteDestination(PDFRenderContext context, PDFWriter writer, string name) { PDFDestination dest = _dests[name]; writer.BeginArrayEntry(); writer.WriteStringLiteral(name); writer.EndArrayEntry(); writer.BeginArrayEntry(); dest.OutputToPDF(context, writer); writer.EndArrayEntry(); writer.WriteLine(); return(true); }
public PDFObjectRef[] OutputContentsToPDF(PDFRenderContext context, PDFWriter writer) { List <PDFObjectRef> refs = new List <PDFObjectRef>(); foreach (KeyValuePair <string, PDFCategorisedNameTree> kvp in this.InnerDictionary) { PDFObjectRef oref = kvp.Value.OutputToPDF(writer, context); if (null != oref) { refs.Add(oref); } } return(refs.ToArray()); }
public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { if (this.Roots.Count > 0) { if (context.ShouldLogDebug) { context.TraceLog.Begin(TraceLevel.Verbose, "Outline Stack", "Starting to render the outline tree"); } PDFObjectRef outlines = writer.BeginObject(); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Outlines"); PDFObjectRef first, last; int count; this.RenderOutlineCollection(this.Roots, outlines, context, writer, out first, out last, out count); if (null != first) { writer.WriteDictionaryObjectRefEntry("First", first); } if (null != last) { writer.WriteDictionaryObjectRefEntry("Last", last); } if (count > 0) { writer.WriteDictionaryNumberEntry("Count", count); } writer.EndDictionary(); writer.EndObject();//outlines if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Verbose, "Outline Stack", "Finished rendering the outline tree"); } else if (context.ShouldLogVerbose) { context.TraceLog.Add(TraceLevel.Verbose, "Outline Stack", "Rendered the outline tree to indirect object " + outlines + " with first " + first + ", last " + last + " and count " + count); } return(outlines); } else { return(null); } }
/// <summary> /// Overrides the abstract base implementation to render the URI action dictionary to current PDFObject stream in the writer. Returns null. /// </summary> /// <param name="context">The current context</param> /// <param name="writer">The writer to write to</param> /// <returns></returns> public override PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Action"); writer.WriteDictionaryNameEntry("S", "URI"); writer.WriteDictionaryStringEntry("URI", this.Url); writer.EndDictionary(); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Uri Action", "Added Uri destination action to location " + this.Url); } return(null); }
public PDFObjectRef[] OutputContentsToPDF(PDFRenderContext context, PDFWriter writer) { List <PDFObjectRef> entries = new List <PDFObjectRef>(); foreach (PDFAnnotationEntry entry in this._annots) { PDFObjectRef oref = entry.OutputToPDF(context, writer); if (null != oref) { entries.Add(oref); } } return(entries.ToArray()); }
/// <summary> /// Renders the action data within the current object /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public override PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Action"); writer.WriteDictionaryNameEntry("S", "Named"); string name = this.GetNameForAction(this.ActionType); writer.WriteDictionaryNameEntry("N", name); writer.EndDictionary(); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Named Action", "Added named action " + name + "for annotation"); } return(null); }
private void OutputDefaultResources(PDFRenderContext context, PDFWriter writer) { writer.BeginDictionaryEntry("DR"); writer.BeginDictionaryS(); writer.BeginDictionaryEntry("Font"); writer.BeginDictionary(); writer.WriteDictionaryObjectRefEntry("frsc1", new PDFObjectRef(7, 0)); writer.EndDictionary(); writer.EndDictionaryEntry(); writer.EndDictionary(); writer.EndDictionaryEntry(); }
protected override List <PDFObjectRef> OutputAllPages(PDFObjectRef parent, PDFRenderContext context, PDFWriter writer) { if (null != this.OriginalFile) { List <PDFObjectRef> all = new List <PDFObjectRef>(this.OriginalPageRefs); List <PDFObjectRef> added = base.OutputAllPages(parent, context, writer); all.AddRange(added); return(all); } else { return(base.OutputAllPages(parent, context, writer)); } }
private void WriteInputColor(PDFRenderContext context, PDFWriter writer, string key, PDFColor color) { writer.BeginDictionaryEntry(key); if (color.ColorSpace == ColorSpace.RGB) { writer.WriteArrayRealEntries(true, color.Red.Value, color.Green.Value, color.Blue.Value); } else if (color.ColorSpace == ColorSpace.G) { writer.WriteArrayRealEntries(true, color.Gray.Value); } else { writer.BeginArray(); writer.EndArray(); context.TraceLog.Add(TraceLevel.Warning, "Output", "The color space " + color.ColorSpace.ToString() + " is not supported in input backgrounds"); } writer.EndDictionaryEntry(); }
/// <summary> /// Overrides the abstract base method to render the remote destination /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public override PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Action"); writer.WriteDictionaryNameEntry("S", "GoToR"); writer.WriteDictionaryStringEntry("F", this.File); if (!string.IsNullOrEmpty(this.DestinationName)) { writer.WriteDictionaryStringEntry("D", this.DestinationName); } writer.WriteDictionaryBooleanEntry("NewWindow", this.NewWindow); writer.EndDictionary(); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Remote Action", "Added remote destination action to file " + this.File); } return(null); }
public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { if (this.Fields.Count > 0) { PDFObjectRef fields = writer.BeginObject(); writer.BeginDictionary(); OutputFields(context, writer); //OutputDefaultResources(context, writer); writer.EndDictionary(); writer.EndObject(); return(fields); } else { return(null); } }
private void OutputFields(PDFRenderContext context, PDFWriter writer) { writer.BeginDictionaryEntry("Fields"); List <PDFObjectRef> entries = new List <PDFObjectRef>(); Resources.PDFResourceCollection all = new Resources.PDFResourceCollection(this.Owner); foreach (PDFAcrobatFormFieldWidget entry in this.Fields) { PDFObjectRef oref = entry.OutputToPDF(context, writer); if (null != oref) { entries.Add(oref); } } writer.WriteArrayRefEntries(true, entries.ToArray()); List <IPDFResource> rsrs = new List <IPDFResource>(); writer.EndDictionaryEntry(); }
/// <summary> /// Outputs all the names within this dictionary to a new PDFObject in output writer and returns a reference to the dictionary /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { PDFObjectRef names = writer.BeginObject(); writer.BeginDictionary(); if (_dests.Count > 0) { List <string> all = new List <string>(_dests.Keys); all.Sort(); PDFObjectRef dests = WriteDestinationNames(context, writer, all); writer.WriteDictionaryObjectRefEntry("Dests", dests); } writer.EndDictionary(); writer.EndObject(); return(names); }
/// <summary> /// Outputs the entire contents of this name dictionary to the specified writer /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { PDFObjectRef names = null; if (this.InnerDictionary.Count > 0) { names = writer.BeginObject(); writer.BeginDictionary(); foreach (KeyValuePair <string, PDFCategorisedNameTree> kvp in this.InnerDictionary) { PDFObjectRef oref = kvp.Value.OutputToPDF(writer, context); if (null != oref) { writer.WriteDictionaryObjectRefEntry(kvp.Key, oref); } } writer.EndDictionary(); writer.EndObject(); } return(names); }
protected override PDFObjectRef DoOutputToPDF(PDFRenderContext context, PDFWriter writer) { if (null != this.OriginalFile) { writer.OpenDocument(this.OriginalFile, true); PDFObjectRef catalog = this.WriteCatalog(context, writer); this.WriteInfo(context, writer); PDFDocumentID id = this.DocumentComponent.DocumentID; if (null == id) { id = PDFDocumentID.Create(); } writer.CloseDocument(id); return(catalog); } else { return(base.DoOutputToPDF(context, writer)); } }
/// <summary> /// Writes all the destinations to the current PDF Object /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <param name="all"></param> /// <returns></returns> private PDFObjectRef WriteDestinationNames(PDFRenderContext context, PDFWriter writer, IEnumerable <string> all) { PDFObjectRef dests = writer.BeginObject(); writer.BeginDictionary(); //Write the names array writer.BeginDictionaryEntry("Names"); writer.BeginArray(); string firstname = string.Empty; string lastname = string.Empty; foreach (string name in all) { if (WriteDestination(context, writer, name)) { if (string.IsNullOrEmpty(firstname)) { firstname = name; } lastname = name; } } writer.EndArray(); writer.EndDictionaryEntry(); //Write limits writer.BeginDictionaryEntry("Limits"); writer.WriteArrayStringEntries(firstname, lastname); writer.EndDictionaryEntry(); writer.EndDictionary(); writer.EndObject(); return(dests); }
/// <summary> /// Overrides the base abstract method to write the action dictionary to the current object. /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public override PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { if (null == this.Destination) { throw new NullReferenceException(string.Format("Destination cannot be null for the destination action on component '{0}'", this.Component)); } writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Action"); writer.WriteDictionaryNameEntry("S", "GoTo"); //The destination should be registered with the Name Dictionary //so we use the full name here to refer to it. writer.WriteDictionaryStringEntry("D", this.Destination.FullName); writer.EndDictionaryEntry(); writer.EndDictionary(); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Destination Action", "Added destination action " + this.Destination.FullName + "for annotation"); } return(null); }
private PDFObjectRef RenderOutlineItem(PDFOutlineRef outlineref, PDFObjectRef parent, PDFObjectRef prev, PDFRenderContext context, PDFWriter writer, out int count) { PDFOutline outline = outlineref.Outline; Scryber.Drawing.PDFColor c = outlineref.GetColor(); Scryber.Drawing.FontStyle fs = outlineref.GetFontStyle(); bool isopen = outlineref.GetIsOpen(); count = 1;//this one PDFObjectRef item = writer.BeginObject(); writer.BeginDictionary(); writer.WriteDictionaryObjectRefEntry("Parent", parent); writer.WriteDictionaryStringEntry("Title", outline.Title); writer.WriteDictionaryStringEntry("Dest", outline.DestinationName); if (null != c) { writer.BeginDictionaryEntry("C"); writer.BeginArray(); writer.WriteRealS(c.Red.Value, c.Green.Value, c.Blue.Value); writer.EndArray(); writer.EndDictionaryEntry(); } if (fs != Scryber.Drawing.FontStyle.Regular) { int f = 0; if ((fs & Scryber.Drawing.FontStyle.Bold) > 0) { f = 2; } if ((fs & Scryber.Drawing.FontStyle.Italic) > 0) { f += 1; } writer.WriteDictionaryNumberEntry("F", f); } if (null != prev) { writer.WriteDictionaryObjectRefEntry("Prev", prev); } if (context.ShouldLogVerbose) { context.TraceLog.Add(TraceLevel.Verbose, "Outline Stack", "Rendered outline item " + item + " with title '" + outline.Title + " and destination name " + outline.DestinationName); } if (outlineref.HasInnerItems) { if (context.ShouldLogDebug) { context.TraceLog.Begin(TraceLevel.Debug, "Outline Stack", "Started rendering inner outline items"); } int opencount; PDFObjectRef childfirst, childlast; this.RenderOutlineCollection(outlineref.InnerItems, item, context, writer, out childfirst, out childlast, out opencount); writer.WriteDictionaryObjectRefEntry("First", childfirst); writer.WriteDictionaryObjectRefEntry("Last", childlast); if (opencount > 0) { if (isopen) { writer.WriteDictionaryNumberEntry("Count", opencount); count += opencount; } else { writer.WriteDictionaryNumberEntry("Count", -opencount); } } if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Debug, "Outlines", " Finished rendering inner outline items"); } } //we don't close the dictionary here as we need the next entry written //It should be closed in the calling method return(item); }
private void RenderOutlineCollection(PDFOutlineRefCollection col, PDFObjectRef parent, PDFRenderContext context, PDFWriter writer, out PDFObjectRef first, out PDFObjectRef last, out int count) { PDFObjectRef prev = null; List <PDFObjectRef> previousitems = new List <PDFObjectRef>(); first = null; last = null; count = 0; int i = 0; do { int innercount; PDFObjectRef one = RenderOutlineItem(col[i], parent, prev, context, writer, out innercount); if (i == 0) { first = one; } if (i == col.Count - 1) { last = one; } i++; prev = one; previousitems.Add(one); count += innercount; } while (i < col.Count); //close all the dictionaries and object in reverse order //adding the next entry first if we are not the last entry for (int p = previousitems.Count - 1; p >= 0; p--) { if (p < previousitems.Count - 1) { writer.WriteDictionaryObjectRefEntry("Next", previousitems[p + 1]); } writer.EndDictionary(); writer.EndObject(); } }
/// <summary> /// No Supported in the Outline Stack /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public PDFObjectRef[] OutputContentsToPDF(PDFRenderContext context, PDFWriter writer) { throw new NotSupportedException("This operation is not supported in Outline stacks"); }
protected override PDFObjectRef DoOutputToPDF(PDFRenderContext context, PDFWriter writer) { List <PDFObjectRef> all = new List <PDFObjectRef>(); if (context.ShouldLogDebug) { context.TraceLog.Begin(TraceLevel.Debug, "Link Annotation", "Outputting all required link annotations for component " + this.Component.UniqueID); } int pageindex = context.PageIndex; PDFComponentArrangement arrange = this.Component.GetFirstArrangement(); int index = 1; while (null != arrange && arrange.PageIndex == pageindex) { PDFObjectRef annotref = writer.BeginObject(); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Annot"); writer.WriteDictionaryNameEntry("Subtype", "Link"); if (!string.IsNullOrEmpty(this.AlternateText)) { writer.WriteDictionaryStringEntry("Contents", this.AlternateText); } PDFRect bounds = arrange.RenderBounds; if (bounds != PDFRect.Empty && bounds.Size != PDFSize.Empty) { if (context.DrawingOrigin == DrawingOrigin.TopLeft) { //PDFs have origin at bottom so need to convert. PDFReal value = context.Graphics.GetXPosition(bounds.X.RealValue); bounds.X = new PDFUnit(value.Value, PageUnits.Points); value = context.Graphics.GetYPosition(bounds.Y.RealValue); bounds.Y = new PDFUnit(value.Value, PageUnits.Points); bounds.Width = bounds.X + bounds.Width; bounds.Height = bounds.Y - bounds.Height; } else { bounds.Width = bounds.X + bounds.Width; bounds.Height = bounds.Y + bounds.Height; } writer.BeginDictionaryEntry("Rect"); writer.WriteArrayRealEntries(bounds.X.Value, bounds.Y.Value, bounds.Width.Value, bounds.Height.Value); writer.EndDictionaryEntry(); } string name = this.Component.UniqueID + "_" + index.ToString(); writer.WriteDictionaryStringEntry("NM", name); //Draw the border StyleValue <LineType> lstyle; /* if (this.AnnotationStyle != null && this.AnnotationStyle.TryGetValue(StyleKeys.BorderStyleKey, out lstyle) && lstyle != null && lstyle.Value != LineType.None) * { * PDFUnit corner = this.AnnotationStyle.GetValue(StyleKeys.BorderCornerRadiusKey, (PDFUnit)0); * PDFUnit width = this.AnnotationStyle.GetValue(StyleKeys.BorderWidthKey, (PDFUnit)1); * PDFColor c = this.AnnotationStyle.GetValue(StyleKeys.BorderColorKey, PDFColors.Transparent); * * if (c != null && width > 0) * { * writer.BeginDictionaryEntry("Border"); * writer.WriteArrayRealEntries(corner.PointsValue, corner.PointsValue, width.PointsValue); * writer.EndDictionaryEntry(); * * writer.BeginDictionaryEntry("C"); * if (c.ColorSpace == ColorSpace.G) * writer.WriteArrayRealEntries(c.Gray.Value); * else if (c.ColorSpace == ColorSpace.RGB) * writer.WriteArrayRealEntries(c.Red.Value, c.Green.Value, c.Blue.Value); * else if (context.Conformance == ParserConformanceMode.Strict) * RecordAndRaise.ArgumentOutOfRange("c", Errors.ColorValueIsNotCurrentlySupported, c.ColorSpace); * else * context.TraceLog.Add(TraceLevel.Error, "Link Annotation", string.Format(Errors.ColorValueIsNotCurrentlySupported, c.ColorSpace)); * * writer.EndDictionaryEntry(); * } * * } * else * { */ writer.BeginDictionaryEntry("Border"); //writer.WriteArrayRealEntries(1.0, 1.0, 1.0); writer.WriteArrayRealEntries(0.0, 0.0, 0.0); writer.EndDictionaryEntry(); //} if (null != this.Action) { writer.BeginDictionaryEntry("A"); PDFObjectRef actionref = this.Action.OutputToPDF(context, writer); if (null != actionref) { writer.WriteObjectRefS(actionref); } writer.EndDictionaryEntry(); } writer.EndDictionary(); writer.EndObject(); if (context.ShouldLogDebug) { context.TraceLog.Add(TraceLevel.Debug, "Link Annotation", "Annotation added " + name + " for bounds " + bounds + " on page " + context.PageIndex); } all.Add(annotref); //If we have more than one arrangement on the object then move to the next one if (arrange is PDFComponentMultiArrangement) { arrange = ((PDFComponentMultiArrangement)arrange).NextArrangement; } index++; } if (all.Count == 0) { if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Debug, "Link Annotation", "No required link annotations for component " + this.Component.UniqueID); } return(null); } else if (all.Count == 1) { return(all[0]); } else { if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Debug, "Link Annotation", "All " + all.Count + " link annotations for component " + this.Component.UniqueID + " were output"); } PDFObjectRef array = writer.BeginObject(); writer.WriteArrayRefEntries(all.ToArray()); writer.EndObject(); return(array); } }
public PDFRenderEventArgs(PDFRenderContext context) { this.Context = context; }
protected override PDFObjectRef OutputPageTree(PDFRenderContext context, PDFWriter writer) { this._newPageTree = base.OutputPageTree(context, writer); return(this._newPageTree); }
/// <summary> /// Inheritors must implment this method to generate their own code to render the link action /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public abstract PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer);
public PDFObjectRef[] OutputContentsToPDF(PDFRenderContext context, PDFWriter writer) { throw new NotImplementedException(); }
protected override PDFObjectRef DoOutputToPDF(PDFRenderContext context, PDFWriter writer) { //Get the default font and size required for the DA (default Appearance value) var xObject = this._states[FormFieldAppearanceState.Normal]; if (null == xObject) { return(null); } PDFObjectRef root = writer.BeginObject(); var font = this._style.CreateFont(); var rsrc = xObject.Document.GetResource(Scryber.Resources.PDFResource.FontDefnResourceType, font.FullName, true); string da = rsrc.Name.ToString() + " " + font.Size.ToPoints().Value.ToString() + " Tf"; writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Subtype", "Widget"); writer.WriteDictionaryStringEntry("T", this.Name); if (!string.IsNullOrEmpty(this.Value)) { writer.WriteDictionaryStringEntry("V", this.Value); } if (!string.IsNullOrEmpty(this.DefaultValue)) { writer.WriteDictionaryStringEntry("DV", this.DefaultValue); } writer.WriteDictionaryNumberEntry("Ff", (int)this.FieldOptions + (int)this.FieldType); writer.WriteDictionaryStringEntry("DA", da); writer.WriteDictionaryNameEntry("FT", GetFieldTypeName(this.FieldType)); if (null != this._page && null != this._page.PageObjectRef) { writer.WriteDictionaryObjectRefEntry("P", this._page.PageObjectRef); } //MK - appearance dictionary writer.BeginDictionaryEntry("MK"); writer.BeginDictionary(); if (this._style.IsValueDefined(Styles.StyleKeys.BorderColorKey)) { WriteInputColor(context, writer, "BC", this._style.Border.Color); } if (this._style.IsValueDefined(Styles.StyleKeys.BgColorKey)) { WriteInputColor(context, writer, "BG", this._style.Background.Color); } writer.EndDictionary(); writer.EndDictionaryEntry(); if (this._states.Count > 0) { _location = context.Offset; Drawing.PDFRect bounds = Drawing.PDFRect.Empty; writer.BeginDictionaryEntry("AP"); writer.BeginDictionary(); foreach (var kvp in _states) { xObject = kvp.Value; FormFieldAppearanceState state = kvp.Key; PDFObjectRef oref = xObject.OutputToPDF(context, writer); if (null != oref) { PDFSize sz = new Drawing.PDFSize(xObject.Width, xObject.Height); if (_size == PDFSize.Empty) { _size = sz; } else { if (_size.Width < sz.Width) { _size.Width = sz.Width; } if (_size.Height < sz.Height) { _size.Height = sz.Height; } } var name = GetFieldStateName(kvp.Key); writer.WriteDictionaryObjectRefEntry(name, oref); //We should have all states starting at the same location no matter what. this._location = xObject.Location; } } writer.EndDictionary(); writer.EndDictionaryEntry(); PDFReal left = context.Graphics.GetXPosition(_location.X); PDFReal top = context.Graphics.GetYPosition(_location.Y); PDFReal right = left + context.Graphics.GetXOffset(_size.Width); PDFReal bottom = top + context.Graphics.GetYOffset(_size.Height); writer.BeginDictionaryEntry("Rect"); writer.WriteArrayRealEntries(true, left.Value, bottom.Value, right.Value, top.Value); writer.EndDictionaryEntry(); } writer.EndDictionary(); writer.EndObject(); //context.Offset = new PDFPoint(context.Offset.X, context.Offset.Y + _size.Height); return(root); }