/// <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);
}