Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > TextBox export to PDF

Not answered TextBox export to PDF

Feed from this thread
  • GOURVEZ JJ avatar

    Posted on Jan 30, 2012 (permalink)

    Hi,

    I use an RadChart.
    I want to export it, I use this code : http://demos.telerik.com/silverlight/#Chart/PrintAndExportWithRadDocument

    All it's OK but, I want export TextBox and Label.
    Can you help me ?

    Thanks

    Reply

  • GOURVEZ JJ avatar

    Posted on Feb 1, 2012 (permalink)

    Nobody ???

    Reply

  • Vladimir Milev Vladimir Milev admin's avatar

    Posted on Feb 2, 2012 (permalink)

    Hi,

    To export them to image you can use the export extensions:

    private void Export_Click(object sender, RoutedEventArgs e)
    {
    SaveFileDialog sfd = new SaveFileDialog();
    sfd.DefaultExt = "png";
    sfd.Filter = "PNG File (*.png) | *.png";
    if ((bool)sfd.ShowDialog())
    {
    using (var stream = sfd.OpenFile())
    {
    Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(control_to_export, stream, new PngBitmapEncoder());
    }
    }
    }


    Regards,
    Vladimir Milev
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • GOURVEZ JJ avatar

    Posted on Feb 2, 2012 (permalink)

    Thanks for your answer.
    But I want export to PDF.
    Does it possible ?
    Thanks

    Reply

  • GOURVEZ JJ avatar

    Posted on Feb 7, 2012 (permalink)

    Hi,

    Does it possible to export to PDF ? (Radchart, textbox and  label)

    Thanks

    Reply

  • Iva Toteva Iva Toteva admin's avatar

    Posted on Feb 7, 2012 (permalink)

    Hi GOURVEZ,

    You can use RadDocument and PdfFormatProvider to create a document and export it to PDF. You can find more information on this in our online documentation, in the articles about RadDocument and the FormatProviders.
    In a nutshell, what you can do is use the export extension method from Vladimir's post to create an image out of the control you wish to export, insert this image into the document and save the document to PDF. This can be done as follows:

    private void Export_Click(object sender, System.Windows.RoutedEventArgs e)
    {
        SaveFileDialog sfd = new SaveFileDialog();
        sfd.DefaultExt = "pdf";
        sfd.Filter = "PDF File (*.pdf) | *.pdf";
        if ((bool)sfd.ShowDialog())
        {
            RadDocument document = new RadDocument();
            using (var stream = new MemoryStream())
            {
                Telerik.Windows.Media.Imaging.ExportExtensions.ExportToImage(controlToExport, stream, new PngBitmapEncoder());
                stream.Flush();
                stream.Seek(0, SeekOrigin.Begin);
                document.InsertInline(new ImageInline(stream));
            }
            using (var stream = sfd.OpenFile())
            {
                PdfFormatProvider pdf = DocumentFormatProvidersManager.GetProviderByExtension("pdf") as PdfFormatProvider;
                pdf.Export(document, stream);
            }
        }
    }

    Note that if the size of the control is bigger than the size of the page, part of the image may be cropped (similarly to how Word exports large pictures to PDF).

    I hope this helps.

    Greetings,
    Iva Toteva
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • GOURVEZ JJ avatar

    Posted on Feb 8, 2012 (permalink)

    Hi,

    It's perfect !

    Thanks

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Chart > TextBox export to PDF
Related resources for "TextBox export to PDF"

Silverlight Chart Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]