public PDFLayoutXObject(PDFLayoutLine parent, PDFLayoutRegion childContainer, PDFPositionOptions position, IPDFComponent owner) : base(parent, owner as IPDFComponent) { this._childContainer = childContainer; this._resources = new PDFResourceList(this, false); this.SubType = "Form"; this.Matrix = PDFTransformationMatrix.Identity(); this._position = position; }
private PDFTransformationMatrix CalculateMatrix(PDFSize available, PDFRect view, SVGAspectRatio ratio) { PDFTransformationMatrix matrix = PDFTransformationMatrix.Identity(); if (ratio.Align == AspectRatioAlign.None) { SVGAspectRatio.ApplyMaxNonUniformScaling(matrix, available, view); } else if (ratio.Meet == AspectRatioMeet.Meet) { SVGAspectRatio.ApplyUniformScaling(matrix, available, view, ratio.Align); } else if (ratio.Meet == AspectRatioMeet.Slice) { SVGAspectRatio.ApplyUniformStretching(matrix, available, view, ratio.Align); } else { throw new ArgumentOutOfRangeException(nameof(ratio)); } return(matrix); }
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(); } }