ComponentOne PDF for WPF and Silverlight
Drawing Framework Element Objects
PDF for WPF and Silverlight Overview > Task-Based Help > Drawing Framework Element Objects

You can use the C1PDFDocument.DrawElement method to draw the framework element objects like the following:

To write the code in Visual Basic:

  Private Sub CreateVisualTree(pdf As C1PdfDocument, targetElement As FrameworkElement)


 ' set up to render

 Dim font = New Font("Courier", 14)

 

 ' go render

 Dim firstPage = True

 For Each stretch__1 As Stretch In New Stretch() {Stretch.Fill, Stretch.None, Stretch.Uniform, Stretch.UniformToFill}


  ' add pagebreak

  If Not firstPage Then

 

   pdf.NewPage()
  End If

  firstPage = False

 

  ' set up to render

  Dim alignment = ContentAlignment.TopLeft

  Dim rc = PdfUtils.Inflate(pdf.PageRectangle, -72, -72)

 

  ' render element

  pdf.DrawString("Element as VisualTree, Stretch: " + stretch__1.ToString(), font, Colors.Black, rc)

  rc = PdfUtils.Inflate(rc, -20, -20)


  pdf.DrawElement(targetElement, rc, alignment, stretch__1)
 Next

End Sub

 

To write the code in C#:

  void CreateVisualTree(C1PdfDocument pdf, FrameworkElement targetElement)
        {
            // set up to render
            var font = new Font("Courier", 14);
            // go render
            var firstPage = true;
            foreach (Stretch stretch in new Stretch[] { Stretch.Fill, Stretch.None, Stretch.Uniform, Stretch.UniformToFill })
            {
                // add pagebreak
                if (!firstPage)
                {
                    pdf.NewPage();
                }
                firstPage = false;
                // set up to render
                var alignment = ContentAlignment.TopLeft;
                var rc = PdfUtils.Inflate(pdf.PageRectangle, -72, -72);
                // render element
                pdf.DrawString("Element as VisualTree, Stretch: " + stretch.ToString(), font, Colors.Black, rc);
                rc = PdfUtils.Inflate(rc, -20, -20);
                pdf.DrawElement(targetElement, rc, alignment, stretch);
            }
        }