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); } }
protected virtual PDFObjectRef RenderShadingDictionary(PDFContextBase context, PDFWriter writer) { writer.BeginDictionaryEntry("Shading"); writer.BeginDictionary(); writer.BeginDictionaryEntry("ShadingType"); writer.WriteNumberS((int)ShadingType.Axial); writer.EndDictionaryEntry(); writer.WriteDictionaryNameEntry("ColorSpace", "DeviceRGB"); writer.BeginDictionaryEntry("BBox"); 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); writer.WriteArrayRealEntries(true, offset.X.PointsValue, offset.Y.PointsValue, offset.X.PointsValue + size.Width.PointsValue, offset.Y.PointsValue + size.Height.PointsValue); writer.EndDictionaryEntry(); writer.WriteDictionaryBooleanEntry("AntiAlias", true); writer.BeginDictionaryEntry("Coords"); var coords = GetCoords(offset, size, this._descriptor.Angle); writer.WriteArrayRealEntries(true, coords); var func = this._descriptor.GetGradientFunction(offset, size); if (null != func) { writer.BeginDictionaryEntry("Function"); func.WriteFunctionDictionary(context, writer); writer.EndDictionaryEntry(); } writer.EndDictionary();//shading return(null); }
/// <summary> /// Writes the value of the number to the current PDFWriter /// </summary> /// <param name="writer">The PDFWriter to write to</param> public void WriteData(PDFWriter writer) { writer.WriteNumberS(this.Value); }
protected virtual PDFObjectRef OutputContent(PDFRenderContext context, PDFWriter writer) { PDFObjectRef oref = writer.BeginObject(); IStreamFilter[] filters = (context.Compression == OutputCompressionType.FlateDecode) ? this.PageCompressionFilters : null; writer.BeginStream(oref, filters); PDFPoint pt = context.Offset.Clone(); PDFSize sz = context.Space.Clone(); using (PDFGraphics g = this.CreateGraphics(writer, context.StyleStack, context)) { context.Graphics = g; if (null != this.HeaderBlock) { this.HeaderBlock.OutputToPDF(context, writer); } this.ContentBlock.OutputToPDF(context, writer); if (null != this.FooterBlock) { this.FooterBlock.OutputToPDF(context, writer); } if (_outputbadge) { this.PaintBadgeXObj(context, writer); } } context.Offset = pt; context.Space = sz; long len = writer.EndStream(); writer.BeginDictionary(); if (null != filters && filters.Length > 0) { writer.BeginDictionaryEntry("Length"); writer.WriteNumberS(len); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("Filter"); writer.BeginArray(); foreach (IStreamFilter filter in filters) { writer.BeginArrayEntry(); writer.WriteName(filter.FilterName); writer.EndArrayEntry(); } writer.EndArray(); writer.EndDictionaryEntry(); } else { writer.BeginDictionaryEntry("Length"); writer.WriteNumberS(len); writer.EndDictionaryEntry(); } writer.EndDictionary(); writer.EndObject(); return(oref); }
private void WriteXObjectDictionaryContent(PDFRenderContext context, PDFWriter writer, long len, IStreamFilter[] filters) { writer.WriteDictionaryNameEntry("Type", "XObject"); if (!string.IsNullOrEmpty(this.SubType)) { writer.WriteDictionaryNameEntry("Subtype", "Form"); } writer.BeginDictionaryEntry("Matrix"); writer.WriteArrayRealEntries(PDFTransformationMatrix.Identity().Components); // this.Matrix.Components); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("BBox"); writer.BeginArrayS(); if (this._position.ViewPort.HasValue) { PDFRect vp = this._position.ViewPort.Value; writer.WriteReal(vp.X.PointsValue); writer.WriteRealS(vp.Y.PointsValue); writer.WriteRealS(vp.Width.PointsValue); writer.WriteRealS(vp.Height.PointsValue); } else { writer.WriteReal(0.0F); writer.WriteRealS(0.0F); writer.WriteRealS(this._childContainer.Height.PointsValue); writer.WriteRealS(this._childContainer.Height.PointsValue); } writer.EndArray(); writer.EndDictionaryEntry(); PDFObjectRef res = this._resources.WriteResourceList(context, writer); if (null != res) { writer.WriteDictionaryObjectRefEntry("Resources", res); } if (null != filters && filters.Length > 0) { writer.BeginDictionaryEntry("Length"); writer.WriteNumberS(len); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("Filter"); writer.BeginArray(); foreach (IStreamFilter filter in filters) { writer.BeginArrayEntry(); writer.WriteName(filter.FilterName); writer.EndArrayEntry(); } writer.EndArray(); writer.EndDictionaryEntry(); } else { writer.BeginDictionaryEntry("Length"); writer.WriteNumberS(len); writer.EndDictionaryEntry(); } }
// // methods // #region protected override PDFObjectRef DoRenderToPDF(PDFContextBase context, PDFWriter writer) /// <summary> /// Renders the tiling image /// </summary> /// <param name="context"></param> /// <param name="writer"></param> /// <returns></returns> protected override PDFObjectRef DoRenderToPDF(PDFContextBase context, PDFWriter writer) { IStreamFilter[] filters = writer.DefaultStreamFilters; PDFObjectRef pattern = writer.BeginObject(); writer.BeginDictionary(); writer.WriteDictionaryNameEntry("Type", "Pattern"); writer.WriteDictionaryNumberEntry("PatternType", (int)this.PatternType); writer.WriteDictionaryNumberEntry("PaintType", (int)this.PaintType); writer.WriteDictionaryNumberEntry("TilingType", (int)this.TilingType); writer.BeginDictionaryEntry("BBox"); PDFPoint offset = new PDFPoint(this.Start.X, this.Start.Y - this.ImageSize.Height);// this.Start; PDFSize size = this.ImageSize; PDFSize graphicsSize = new PDFSize(size.Width + offset.X, size.Height + offset.Y); writer.WriteArrayRealEntries(true, offset.X.PointsValue, offset.Y.PointsValue, offset.X.PointsValue + size.Width.PointsValue, offset.Y.PointsValue + size.Height.PointsValue); writer.EndDictionaryEntry(); writer.WriteDictionaryRealEntry("XStep", this.Step.Width.PointsValue); writer.WriteDictionaryRealEntry("YStep", this.Step.Height.PointsValue); PDFObjectRef all = this.Resources.WriteResourceList(context, writer); writer.WriteDictionaryObjectRefEntry("Resources", all); writer.BeginStream(pattern); using (PDFGraphics g = PDFGraphics.Create(writer, false, this, DrawingOrigin.TopLeft, graphicsSize, context)) { offset = new PDFPoint(offset.X, 0.0); g.PaintImageRef(this.Image, size, offset); } long len = writer.EndStream(); if (null != filters && filters.Length > 0) { writer.BeginDictionaryEntry("Length"); writer.WriteNumberS(len); writer.EndDictionaryEntry(); writer.BeginDictionaryEntry("Filter"); writer.BeginArray(); foreach (IStreamFilter filter in filters) { writer.BeginArrayEntry(); writer.WriteName(filter.FilterName); writer.EndArrayEntry(); } writer.EndArray(); writer.EndDictionaryEntry(); } else { writer.BeginDictionaryEntry("Length"); writer.WriteNumberS(len); writer.EndDictionaryEntry(); } writer.EndDictionary(); writer.EndObject(); return(pattern); }