This is a migrated thread and some comments may be shown as answers.

Error exporting to pdf

0 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sergey
Top achievements
Rank 1
Sergey asked on 16 Nov 2012, 03:18 PM

I’m trying to save Silverlight controls to pdf, but the code crushes at the line, that saves the actual file with an error:

“Could not load file or assembly 'Telerik.Windows.Zip, Version=2012.2.725.1050, Culture=neutral, PublicKeyToken=5803cfa389c90ce7' or one of its dependencies. The system cannot find the file specified.”

I downloaded a sample from telerik forum, and it works fine with the same code.
I use VS2010 and Silverlight 5. I checked all assemblies and they are all of the same version

private void export(object sender, RoutedEventArgs e)
{
    SaveFileDialog sfd = new SaveFileDialog();
    Section section = new Section();
    Paragraph paragraph = new Paragraph();
    BitmapImage img = new BitmapImage();
    sfd.DefaultExt = "pdf";
    sfd.Filter = "PDF File (*.pdf) | *.pdf";
    if (sfd.ShowDialog() == true)
    {
        RadDocument document = new RadDocument();
        using (MemoryStream stream = new MemoryStream())
        {
            ExportExtensions.ExportToImage((FrameworkElement)LayoutRoot, stream, new PngBitmapEncoder());
            img.SetSource(stream);
        }
        ImageInline image = new ImageInline(new WriteableBitmap(img));
        paragraph.Inlines.Add(image);
        section.Blocks.Add(paragraph);
        document.Sections.Add(section);
        PdfFormatProvider pdf = new PdfFormatProvider();
        using (Stream os = sfd.OpenFile())
        {                  
            pdf.Export(document, os); //this line throws the exception
        }
    }
}

Tags
General Discussions
Asked by
Sergey
Top achievements
Rank 1
Share this question
or