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
}
}
}