/// <summary> /// Builds a PdfFormXObject from the specified brush. /// </summary> PdfFormXObject BuildForm(VisualBrush brush) { //<< // /BBox [0 100 100 0] // /Length 65 // /Matrix [1 0 0 1 0 0] // /Resources // << // /ColorSpace // << // /CS0 15 0 R // >> // /ExtGState // << // /GS0 10 0 R // >> // /ProcSet [/PDF /ImageC /ImageI] // /XObject // << // /Im0 16 0 R // >> // >> // /Subtype /Form //>> //stream // q // 0 0 100 100 re // W n // q // /GS0 gs // 100 0 0 -100 0 100 cm // /Im0 Do // Q //Q //endstream PdfFormXObject pdfForm = Context.PdfDocument.Internals.CreateIndirectObject <PdfFormXObject>(); double width = brush.Viewport.Width; double height = brush.Viewport.Height; pdfForm.DpiX = 96; pdfForm.DpiY = 96; // view box XRect box = new XRect(0, 0, width, height); pdfForm.Elements.SetRectangle(PdfFormXObject.Keys.BBox, new PdfRectangle(0, height, width, 0)); pdfForm.Elements.SetMatrix(PdfFormXObject.Keys.Matrix, new XMatrix()); PdfContentWriter writer = new PdfContentWriter(Context, pdfForm); pdfForm.Elements.SetMatrix(PdfFormXObject.Keys.Matrix, new XMatrix()); writer.BeginContentRaw(); writer.WriteLiteral("-100 Tz\n"); XMatrix matrix = new XMatrix(width, 0, 0, -height, 0, height); writer.WriteLiteral("q\n"); //writer.WriteMatrix(matrix); writer.WriteVisual(brush.Visual); writer.WriteLiteral("Q\n"); #if DEBUG if (DevHelper.BorderPatterns) { writer.WriteLiteral("1 1 1 rg 0 0 m {0:0.###} 0 l {0:0.###} {1:0.###} l 0 {1:0.###} l h s\n", width, height); } #endif writer.EndContent(); return(pdfForm); }
/// <summary> /// Builds a PdfFormXObject from the specified brush. /// </summary> PdfFormXObject BuildForm(VisualBrush brush) { //<< // /BBox [0 100 100 0] // /Length 65 // /Matrix [1 0 0 1 0 0] // /Resources // << // /ColorSpace // << // /CS0 15 0 R // >> // /ExtGState // << // /GS0 10 0 R // >> // /ProcSet [/PDF /ImageC /ImageI] // /XObject // << // /Im0 16 0 R // >> // >> // /Subtype /Form //>> //stream // q // 0 0 100 100 re // W n // q // /GS0 gs // 100 0 0 -100 0 100 cm // /Im0 Do // Q //Q //endstream PdfFormXObject pdfForm = Context.PdfDocument.Internals.CreateIndirectObject<PdfFormXObject>(); pdfForm.DpiX = 96; pdfForm.DpiY = 96; // view box var box = new PdfRectangle(brush.Viewbox.X, brush.Viewbox.Y + brush.Viewbox.Height - 1, brush.Viewbox.X + brush.Viewbox.Width - 1, brush.Viewbox.Y); pdfForm.Elements.SetRectangle(PdfFormXObject.Keys.BBox, box); pdfForm.Elements.SetMatrix(PdfFormXObject.Keys.Matrix, new XMatrix()); PdfContentWriter writer = new PdfContentWriter(Context, pdfForm); pdfForm.Elements.SetMatrix(PdfFormXObject.Keys.Matrix, new XMatrix()); writer.BeginContentRaw(); writer.WriteLiteral("-100 Tz\n"); writer.WriteLiteral("q\n"); writer.WriteVisual(brush.Visual); writer.WriteLiteral("Q\n"); #if DEBUG if (DevHelper.BorderPatterns) writer.WriteLiteral("1 1 1 rg 0 0 m {0:0.###} 0 l {0:0.###} {1:0.###} l 0 {1:0.###} l h s\n", brush.Viewbox.Width, brush.Viewbox.Height); #endif writer.EndContent(); return pdfForm; }