Hi Telerik,
I neeed to save pdf file in my local hard drive which is opend in RadPdfViewer how to achive this.
I followed this link but tht sample is not working http://www.telerik.com/community/forums/silverlight/pdfviewer/save-pdf-file.aspx
it throughing the followimng error "
I am following MVVM Pattern how to this in this pattern
I tried one sample , Here i don't know where i need to give the save path in SaveExexute() Method.
Even I am unable to load the pdf file in MVVM Pattern.
View Model:
Kindly help me anyone
I neeed to save pdf file in my local hard drive which is opend in RadPdfViewer how to achive this.
I followed this link but tht sample is not working http://www.telerik.com/community/forums/silverlight/pdfviewer/save-pdf-file.aspx
it throughing the followimng error "
Error 1 'PdfViewerCommands.Commands.CustomOpenCommand' does not contain a definition for 'viewer' and no extension method 'viewer' accepting a first argument of type 'PdfViewerCommands.Commands.CustomOpenCommand' could be found (are you missing a using directive or an assembly reference?) c:\users\mandapellyr\desktop\357895_pdfviewercommands\pdfviewercommands\pdfviewercommands\commands\customopencommand.cs 51 22 PdfViewerCommands
"I am following MVVM Pattern how to this in this pattern
I tried one sample , Here i don't know where i need to give the save path in SaveExexute() Method.
Even I am unable to load the pdf file in MVVM Pattern.
View Model:
using
System;
using
System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Ink;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
Telerik.Windows.Documents.Fixed;
using
System.ComponentModel;
using
System.Collections.ObjectModel;
using
GalaSoft.MvvmLight.Command;
using
System.IO;
namespace
PDFViewerMultifulPDFsDisplayMVVM
{
public
class
PDFViewmodel
{
private
Stream documentStream;
public
PDFViewmodel()
{
showPdf();
SaveCommand =
new
RelayCommand(SaveExexute);
}
public
RelayCommand SaveCommand {
get
;
set
; }
private
PdfDocumentSource _pdfsou;
public
PdfDocumentSource pdfso
{
get
{
return
_pdfsou; }
set
{ _pdfsou = value; }
}
public
void
showPdf()
{
var str = App.GetResourceStream(
new
System.Uri(
"/PDFViewerMultifulPDFsDisplayMVVM;component/RadPDFViewer_For_Silverlight_and_WPF.pdf"
, System.UriKind.Relative)).Stream;
this
.pdfso =
new
PdfDocumentSource(str);
//this.pdfviewer.DocumentSource = new PdfDocumentSource(str);
}
public
void
SaveExexute()
{
SaveFileDialog saveFileDialog =
new
SaveFileDialog();
saveFileDialog.Filter =
"PDF file (*.pdf)|*.pdf"
;
if
(saveFileDialog.ShowDialog() ==
true
)
{
using
(Stream saveStream = saveFileDialog.OpenFile())
{
documentStream.Seek(0, SeekOrigin.Begin);
documentStream.CopyTo(saveStream);
documentStream.Flush();
saveStream.Flush();
}
}
}
}
}
<
UserControl
x:Class
=
"PDFViewerMultifulPDFsDisplayMVVM.StategicView"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:vm
=
"clr-namespace:PDFViewerMultifulPDFsDisplayMVVM"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"400"
>
<
UserControl.Resources
>
<
vm:PDFViewmodel
x:Key
=
"pdfraja"
/>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
DataContext
=
"{StaticResource pdfraja}"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
Grid
Grid.Row
=
"1"
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"50"
/>
<
RowDefinition
Height
=
"200"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
telerik:RadToolBar
DataContext
=
"{Binding ElementName=PdfViewer, Path=Commands}"
Grid.Row
=
"3"
>
<
telerik:RadButton
Padding
=
"4"
Command
=
"{Binding OpenPdfDocumentCommand}"
>
<
ToolTipService.ToolTip
>
<
TextBlock
Text
=
"Open"
/>
</
ToolTipService.ToolTip
>
<
Image
Source
=
"/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/open.png"
Stretch
=
"None"
/>
</
telerik:RadButton
>
<
telerik:RadButton
Padding
=
"4"
DataContext
=
"{StaticResource pdfraja}"
Command
=
"{Binding SaveCommand}"
>
<
ToolTipService.ToolTip
>
<
TextBlock
Text
=
"Save"
/>
</
ToolTipService.ToolTip
>
<
Image
Source
=
"/PDFViewerMultifulPDFsDisplayMVVM;component/Image/save.png"
Stretch
=
"Fill"
/>
</
telerik:RadButton
>
</
telerik:RadToolBar
>
<
telerik:RadPdfViewer
x:Name
=
"PdfViewer"
DocumentSource
=
"{Binding Pdfso}"
Grid.Row
=
"4"
Height
=
"400"
/>
</
Grid
>
</
Grid
>
</
UserControl
>
Kindly help me anyone