This is a migrated thread and some comments may be shown as answers.
Export UIElement to PDF in Silverlight
1 Answer 33 Views
This is a migrated thread and some comments may be shown as answers.
Bjorn
Top achievements
Rank 1
Bjorn asked on 03 Aug 2011, 07:03 PM
Hi,

I did some searching through your website and some googling but i can't find a proper answer.

I think i saw an example once where you could export an UIElement as PDF in Silverlight using the Export library (?!)

is this true? If so, could you point me to this example or otherwise indicate if this is possible and give some pointers to look at?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Bjorn
Top achievements
Rank 1
answered on 03 Aug 2011, 07:24 PM
I found it.

http://www.telerik.com/help/silverlight/radrichtextbox-features-import-export.html

together with

http://www.telerik.com/help/silverlight/radrichtextbox-features-document-elements-raddocument.html

showed me how to do it.

here is a code snippit:

private void PrintToPDF()
{
    Section section = new Section();
    Paragraph paragraph = new Paragraph();
    InlineUIContainer container = new InlineUIContainer();
    container.UiElement = new PrintLayout(this.map);
    container.Height = 400;
    container.Width = 400;
    paragraph.Inlines.Add(container);
    section.Blocks.Add(paragraph);
    RadDocument document = new RadDocument();
    document.DefaultPageLayoutSettings = new PageLayoutSettings(PaperTypes.Letter);
    document.Children.Add(section);
    PdfFormatProvider provider = new PdfFormatProvider();
    string extension = "pdf";
    SaveFileDialog dialog = new SaveFileDialog()
    {
        DefaultExt = extension,
        Filter = String.Format("{1} file (*.{0})|*.{0}|All files (*.*)|*.*", extension, "PDF"),
        FilterIndex = 1
    };
    bool? dialogResult = dialog.ShowDialog();
    if (dialogResult == true)
    {
        using (Stream output = dialog.OpenFile())
        {
            provider.Export(document, output);
            MessageBox.Show("Saved Successfuly!");
        }
    }
}
Asked by
Bjorn
Top achievements
Rank 1
Answers by
Bjorn
Top achievements
Rank 1
Share this question
or