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); }
// // methods // #region public virtual PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) + Support methods /// <summary> /// Outputs this Info to the current writer /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> public virtual PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { PDFObjectRef inforef = writer.BeginObject("Info"); writer.BeginDictionary(); OutputInfoEntry("Title", this.Title, writer); OutputInfoEntry("Subject", this.Subject, writer); OutputInfoEntry("Author", this.Author, writer); OutputInfoEntry("Keywords", this.Keywords, writer); OutputInfoEntry("Producer", this.Producer, writer); OutputInfoEntry("Creator", this.Creator, writer); OutputInfoEntry("CreationDate", this.CreationDate, writer); OutputInfoEntry("ModDate", this.ModifiedDate, writer); if (this.HasTrapping) { writer.WriteDictionaryNameEntry("Trapped", this.Trapped.ToString()); } if (this.HasExtras) { foreach (PDFDocumentInfoExtra extra in this.Extras) { OutputInfoEntry(extra.Name, extra.Value, writer); } } writer.EndDictionary(); writer.EndObject(); return(inforef); }
/// <summary> /// Outputs the first Page tree Component and calls Output on each of the layout pages. /// </summary> /// <param name="context">The current context</param> /// <param name="writer">The current writer</param> /// <returns>A reference to the current page tree root Component</returns> protected virtual PDFObjectRef OutputPageTree(PDFRenderContext context, PDFWriter writer) { //Begin the Pages object and dictionary PDFObjectRef pgs = writer.BeginObject(Const.PageTreeName); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Pages"); List <PDFObjectRef> pagerefs = OutputAllPages(pgs, context, writer); //write the kids array entry in the dictionary writer.BeginDictionaryEntry("Kids"); writer.BeginArray(); foreach (PDFObjectRef kid in pagerefs) { writer.BeginArrayEntry(); writer.WriteFileObject(kid); writer.EndArrayEntry(); } writer.EndArray(); //Write the total number of pages to the dictionary writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("Count"); writer.WriteNumber(pagerefs.Count); writer.EndDictionaryEntry(); //close the ditionary and the object writer.EndDictionary(); writer.EndObject(); return(pgs); }
// // methods // public virtual PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer) { if (this.IsEmpty()) { if (context.ShouldLogMessage) { context.TraceLog.Add(TraceLevel.Message, "Viewer Preferences", "No values set on the document viewer preferences so not outputting"); } return(null); } else { PDFObjectRef oref = writer.BeginObject(); writer.BeginDictionary(); this.WriteOptionalFlag("CenterWindow", _centrewindow, context, writer); this.WriteOptionalFlag("FitWindow", _fitwindow, context, writer); this.WriteOptionalFlag("HideWindowUI", _hidewindowui, context, writer); this.WriteOptionalFlag("HideToolbar", _hidetoolbar, context, writer); this.WriteOptionalFlag("HideMenubar", _hidemenubar, context, writer); if (this.NonFullScreenPageDisplay != PageDisplayMode.Undefined) { this.WriteOptionalName("NonFullScreenPageMode", this.NonFullScreenPageDisplay.ToString(), context, writer); } writer.EndDictionary(); writer.EndObject(); return(oref); } }
protected virtual PDFObjectRef DoWritePage(PDFRenderContext context, PDFWriter writer, PDFObjectRef parent) { PDFObjectRef pg = writer.BeginPage(context.PageIndex); this.PageObjectRef = pg; writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Page"); writer.WriteDictionaryObjectRefEntry("Parent", parent); writer.BeginDictionaryEntry("MediaBox"); writer.WriteArrayRealEntries(0.0, 0.0, this.Size.Width.ToPoints().Value, this.Size.Height.ToPoints().Value); writer.EndDictionaryEntry(); if (this.FullStyle.IsValueDefined(StyleKeys.PageAngle)) { int value = this.FullStyle.GetValue(StyleKeys.PageAngle, 0); writer.WriteDictionaryNumberEntry("Rotate", value); } context.PageSize = this.Size; context.Offset = new PDFPoint(); context.Space = context.PageSize; if (context.ShouldLogVerbose) { context.TraceLog.Add(TraceLevel.Verbose, "Layout Page", "Rendering the contents of page : " + this.PageIndex); } PDFObjectRef content = this.OutputContent(context, writer); if (content != null) { writer.WriteDictionaryObjectRefEntry("Contents", content); } if (context.ShouldLogVerbose) { context.TraceLog.Add(TraceLevel.Verbose, "Layout Page", "Rendering the resources of page : " + this.PageIndex); } //PDFObjectRef[] annots = this.DoWriteAnnotations(context, writer); //if (null != annots && annots.Length > 0) //{ // writer.BeginDictionaryEntry("Annots"); // writer.WriteArrayRefEntries(true, annots); // writer.EndDictionaryEntry(); //} PDFObjectRef ress = this.DoWriteResource(context, writer); if (ress != null) { writer.WriteDictionaryObjectRefEntry("Resources", ress); } DoWriteArtefacts(context, writer); writer.EndDictionary(); writer.EndPage(context.PageIndex); return(pg); }
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(); }
internal override PDFObjectRef WriteTo(PDFWriter writer) { PDFObjectRef oref = writer.BeginObject("StandardEncryption"); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Filter", "Standard"); this.WriteStandardSecurityEntries(writer); writer.EndDictionary(); writer.EndObject(); return(oref); }
/// <summary> /// Writes the dictionary entries usign the PDFWriter /// </summary> /// <param name="writer">The PDFWriter to use</param> public void WriteData(PDFWriter writer) { writer.BeginDictionaryS(); foreach (KeyValuePair <PDFName, IFileObject> kvp in this) { writer.BeginDictionaryEntry(kvp.Key); kvp.Value.WriteData(writer); writer.EndDictionaryEntry(); } writer.EndDictionary(); }
protected virtual PDFObjectRef RenderShadingDictionary(PDFContextBase context, PDFWriter writer) { PDFPoint offset = new PDFPoint(this.Start.X, this.Start.Y);// this.Start; PDFSize size = this.Size; PDFSize graphicsSize = new PDFSize(size.Width + offset.X, size.Height + offset.Y); var func = this._descriptor.GetGradientFunction(offset, size); var coords = GetCoords(offset, size, _descriptor.Size, _descriptor.XCentre, _descriptor.YCentre); writer.BeginDictionaryEntry("Shading"); writer.BeginDictionary(); writer.WriteDictionaryNumberEntry("ShadingType", (int)ShadingType.Radial); writer.WriteDictionaryNameEntry("ColorSpace", "DeviceRGB"); writer.WriteDictionaryBooleanEntry("AntiAlias", true); writer.BeginDictionaryEntry("BBox"); writer.WriteArrayRealEntries(true, offset.X.PointsValue, offset.Y.PointsValue, offset.X.PointsValue + size.Width.PointsValue, offset.Y.PointsValue + size.Height.PointsValue); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("Coords"); writer.WriteArrayRealEntries(true, coords); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("Extend"); writer.BeginArray(); writer.BeginArrayEntry(); writer.WriteBooleanS(true); writer.EndArrayEntry(); writer.BeginArrayEntry(); writer.WriteBooleanS(true); writer.EndArrayEntry(); writer.EndArray(); writer.EndDictionaryEntry(); if (null != func) { writer.BeginDictionaryEntry("Function"); func.WriteFunctionDictionary(context, writer); writer.EndDictionaryEntry(); } writer.EndDictionary();//shading return(null); }
private void WriteAPageLabel(PDFRenderContext context, PDFWriter writer, PDFPageNumberRegistration entry) { writer.WriteLine(); writer.BeginArrayEntry(); writer.WriteNumberS(entry.FirstPageIndex); writer.BeginDictionaryS(); string type; switch (entry.Group.NumberStyle) { case PageNumberStyle.Decimals: type = "D"; break; case PageNumberStyle.UppercaseRoman: type = "R"; break; case PageNumberStyle.LowercaseRoman: type = "r"; break; case PageNumberStyle.UppercaseLetters: type = "A"; break; case PageNumberStyle.LowercaseLetters: type = "a"; break; default: type = ""; break; } if (!string.IsNullOrEmpty(type)) { writer.WriteDictionaryNameEntry("S", type); } if (entry.Group.NumberStart > 0) { writer.WriteDictionaryNumberEntry("St", entry.Group.NumberStart + entry.PreviousLinkedRegistrationPageCount); } writer.EndDictionary(); writer.EndArrayEntry(); if (context.ShouldLogVerbose) { context.TraceLog.Add(TraceLevel.Verbose, "Page Labels", "Output the page label entry starting at page index " + entry.FirstPageIndex + " with style " + entry.Group.NumberStyle + ", starting at " + entry.Group.NumberStart); } }
/// <summary> /// Outputs the document catalog (usually the first Component) and then calls output on each of the documents /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> protected virtual PDFObjectRef WriteCatalog(PDFRenderContext context, PDFWriter writer) { PDFObjectRef catalog = writer.BeginObject("Catalog"); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Catalog"); WriteCatalogEntries(context, writer); writer.EndDictionary(); writer.EndObject(); return(catalog); }
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); } }
public PDFObjectRef WriteResourceList(PDFContextBase context, PDFWriter writer) { PDFObjectRef oref = writer.BeginObject(); writer.BeginDictionary(); if (this._includeProcSet) { writer.BeginDictionaryEntry("ProcSet"); writer.WriteArrayNameEntries(ProcSets); writer.EndDictionaryEntry(); } foreach (PDFResourceItemList list in this.types) { writer.BeginDictionaryEntry(list.Type); writer.BeginDictionary(); foreach (PDFResource rsrc in list) { PDFObjectRef rref = rsrc.EnsureRendered(context, writer); if (rref != null) { writer.BeginDictionaryEntry(rsrc.Name); writer.WriteObjectRef(rref); writer.EndDictionaryEntry(); } } writer.EndDictionary(); writer.EndDictionaryEntry(); } writer.EndDictionary(); writer.EndObject(); return(oref); }
/// <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); }
/// <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); }
protected override PDFObjectRef DoRenderToPDF(PDFContextBase context, PDFWriter writer) { PDFObjectRef oref = writer.BeginObject(); writer.BeginDictionaryS(); writer.WriteDictionaryNameEntry("Type", "ExtGState"); foreach (PDFName name in this.States.Keys) { writer.BeginDictionaryEntry(name); this.States[name].WriteData(writer); writer.EndDictionaryEntry(); } writer.EndDictionary(); writer.EndObject(); return(oref); }
public override void WriteFunctionDictionary(PDFContextBase context, PDFWriter writer) { writer.BeginDictionary(); writer.WriteDictionaryNumberEntry("FunctionType", 3); writer.BeginDictionaryEntry("Domain"); writer.WriteArrayRealEntries(this.DomainStart, this.DomainEnd); writer.EndDictionaryEntry(); //The bounds is the function extents of the functions writer.BeginDictionaryEntry("Bounds"); writer.BeginArray(); foreach (var boundary in this.Boundaries) { writer.BeginArrayEntry(); writer.WriteRealS(boundary.Bounds); writer.EndArrayEntry(); } writer.EndArray(); writer.EndDictionaryEntry(); //Write the array of function 2 (Axial aka Linear between 2 colours) List <double> encodes = new List <double>(); writer.BeginDictionaryEntry("Functions"); writer.BeginArray(); foreach (var func in this.Functions) { writer.BeginArrayEntry(); func.WriteFunctionDictionary(context, writer); writer.EndArrayEntry(); //May need to change these values encodes.Add(0); encodes.Add(1); } writer.EndArray(); writer.EndDictionaryEntry(); //Write the encodes for each of the functions 0 1 in a single array writer.BeginDictionaryEntry("Encode"); writer.WriteArrayRealEntries(encodes.ToArray()); writer.EndDictionaryEntry(); writer.EndDictionary(); }
private PDFObjectRef RenderAlpaImageData(PDFContextBase context, PDFWriter writer) { context.TraceLog.Add(TraceLevel.Debug, "IMAGE", "Rendering image alpha mask"); PDFObjectRef mask = writer.BeginObject(); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "XObject"); writer.WriteDictionaryNameEntry("Subtype", "Image"); writer.WriteDictionaryNumberEntry("Width", this.PixelWidth); writer.WriteDictionaryNumberEntry("Height", this.PixelHeight); //writer.WriteDictionaryNumberEntry("Length", this.AlphaData.LongLength); writer.WriteDictionaryNameEntry("ColorSpace", "DeviceGray"); writer.WriteDictionaryNumberEntry("BitsPerComponent", 8); this.WriteFilterNames(context, writer); //writer.EndDictionary(); writer.BeginStream(mask); byte[] data; if (this.HasFilter && this.ShouldApplyFilters(context)) { data = this.GetAlphaFilteredData(this.Filters, context); if (null == data) { data = this.ApplyFiltersToData(this.AlphaData, context); this.SetAlphaFilteredData(this.Filters, data, context); } } else { data = this.AlphaData; } writer.WriteRaw(data, 0, data.Length); writer.EndStream(); //inserted 15/01/15 - Write the filtered length, not the actua image data length to the dictionary. writer.WriteDictionaryNumberEntry("Length", data.Length); writer.EndDictionary(); //end of insert writer.EndObject(); return(mask); }
internal PDFObjectRef Render(PDFName name, PDFContextBase context, PDFWriter writer) { if (context.ShouldLogDebug) { context.TraceLog.Begin(TraceLevel.Message, "Image Data", "Rendering image data for '" + name.ToString() + "'"); } PDFObjectRef renderref = writer.BeginObject(name.Value); writer.BeginDictionaryS(); writer.WriteDictionaryNameEntry("Name", name.Value); writer.WriteDictionaryNameEntry("Type", "XObject"); writer.WriteDictionaryNameEntry("Subtype", "Image"); RenderImageInformation(context, writer); //writer.EndDictionary(); //- commented for data length fix writer.BeginStream(renderref); int length = this.RenderImageStreamData(context, writer); writer.EndStream(); //Added for Data Length fix HRB 15/01/2015 writer.WriteDictionaryNumberEntry("Length", length); writer.EndDictionary(); //End of add writer.EndObject(); if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Message, "Image Data", "Completed render of the image data for '" + name + "' with source " + this.SourcePath); } else { context.TraceLog.Add(TraceLevel.Message, "Image Data", "Rendered the image data for '" + name.ToString() + "' with source " + this.SourcePath); } return(renderref); }
public override void WriteFunctionDictionary(PDFContextBase context, PDFWriter writer) { writer.BeginDictionary(); writer.WriteDictionaryNumberEntry("FunctionType", 2); writer.BeginDictionaryEntry("Domain"); writer.WriteArrayRealEntries(this.DomainStart, this.DomainEnd); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("C0"); writer.WriteArrayRealEntries(this.ColorZero.Red.Value, this.ColorZero.Green.Value, this.ColorZero.Blue.Value); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("C1"); writer.WriteArrayRealEntries(this.ColorOne.Red.Value, this.ColorOne.Green.Value, this.ColorOne.Blue.Value); writer.EndDictionaryEntry(); writer.WriteDictionaryRealEntry("N", this.Exponent); writer.EndDictionary(); //function }
/// <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); }
protected override PDFObjectRef DoRenderToPDF(PDFContextBase context, PDFWriter writer) { PDFObjectRef oref = writer.BeginObject(this.Name.Value); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Pattern"); writer.WriteDictionaryNumberEntry("PatternType", (int)this.PatternType); //Actual shading dictionary var shading = this.RenderShadingDictionary(context, writer); if (null != shading) { writer.WriteDictionaryObjectRefEntry("Shading", shading); } writer.EndDictionary(); writer.EndObject(); return(oref); }
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); } }
/// <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); }
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> /// Writes the collection of page labels and returns a reference to this collection /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> private PDFObjectRef WritePageLabels(PDFRenderContext context, PDFWriter writer) { PDFPageNumbers nums = this.Numbers; PDFObjectRef labels = writer.BeginObject("PageLabels"); writer.BeginDictionary(); writer.BeginDictionaryEntry("Nums"); writer.BeginArrayS(); //PDFPageNumberRegistration def = this.Numbers.; //this.WriteAPageLabel(context, writer, def); foreach (PDFPageNumberRegistration entry in this.Numbers.Registrations) { WriteAPageLabel(context, writer, entry); } writer.EndArray(); writer.EndDictionaryEntry(); writer.EndDictionary(); writer.EndObject(); return(labels); }
/// <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); }
/// <summary> /// This will render the actual content of the XObject graphical content in a new object reference. /// This can then be referred to. /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> private PDFObjectRef OutputContent(PDFRenderContext context, PDFWriter writer) { PDFObjectRef xObject = writer.BeginObject(); IStreamFilter[] filters = (context.Compression == OutputCompressionType.FlateDecode) ? this._page.PageCompressionFilters : null; writer.BeginStream(xObject, filters); this.Location = context.Offset.Offset(0, this.Line.OffsetY); PDFSize origSpace = context.Space.Clone(); PDFGraphics prevGraphics = context.Graphics; using (PDFGraphics g = this.CreateGraphics(writer, context.StyleStack, context)) { context.Graphics = g; g.SaveGraphicsState(); g.RestoreGraphicsState(); context.Offset = Drawing.PDFPoint.Empty; this._childContainer.OutputToPDF(context, writer); } context.Offset = this.Location; context.Space = origSpace; context.Graphics = prevGraphics; long len = writer.EndStream(); writer.BeginDictionary(); this.WriteXObjectDictionaryContent(context, writer, len, filters); writer.EndDictionary(); writer.EndObject(); return(xObject); }
internal PDFObjectRef Render(PDFName name, PDFContextBase context, PDFWriter writer) { if (context.ShouldLogDebug) { context.TraceLog.Begin(TraceLevel.Message, "Path Data", "Rendering path data for '" + name.ToString() + "'"); } PDFObjectRef renderref = writer.BeginObject(name.Value); writer.BeginDictionaryS(); writer.WriteDictionaryNameEntry("Name", name.Value); writer.WriteDictionaryNameEntry("Type", "XObject"); writer.WriteDictionaryNameEntry("Subtype", "Image"); RenderPathInformation(context, writer, renderref); int length = this.RenderPathData(context, writer, renderref); writer.WriteDictionaryNumberEntry("Length", length); writer.EndDictionary(); //End of add writer.EndObject(); if (context.ShouldLogDebug) { context.TraceLog.End(TraceLevel.Message, "Path Data", "Completed render of the path data for '" + name.ToString()); } else { context.TraceLog.Add(TraceLevel.Message, "Path Data", "Rendered the path data for '" + name.ToString()); } return(renderref); }
/// <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); }