Unable to Save PDF file

2 posts, 0 answers
  1. Ramesh
    Ramesh avatar
    22 posts
    Member since:
    Oct 2013

    Posted 02 Jan 2014 Link to this post

    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 "

    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()
                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);

    <UserControl x:Class="PDFViewerMultifulPDFsDisplayMVVM.StategicView"
        d:DesignHeight="300" d:DesignWidth="400">
            <vm:PDFViewmodel x:Key="pdfraja"/>
        <Grid x:Name="LayoutRoot" Background="White" DataContext="{StaticResource pdfraja}">
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            <Grid Grid.Row="1">
                    <RowDefinition Height="50" />
                    <RowDefinition Height="200" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
             <telerik:RadToolBar DataContext="{Binding ElementName=PdfViewer, Path=Commands}"  Grid.Row="3">
                    <telerik:RadButton  Padding="4" Command="{Binding OpenPdfDocumentCommand}">
                            <TextBlock Text="Open"/>
                        <Image Source="/Telerik.Windows.Controls.FixedDocumentViewers;component/Images/open.png"
                                                     Stretch="None" />
                    <telerik:RadButton  Padding="4" DataContext="{StaticResource pdfraja}"  Command="{Binding SaveCommand}">
                            <TextBlock Text="Save"/>
                        <Image Source="/PDFViewerMultifulPDFsDisplayMVVM;component/Image/save.png"
                                                     Stretch="Fill" />
                <telerik:RadPdfViewer x:Name="PdfViewer" DocumentSource="{Binding Pdfso}" Grid.Row="4" Height="400" />

    Kindly help me anyone

  2. Alexander
    Alexander avatar
    41 posts

    Posted 07 Jan 2014 Link to this post

    Hello Ramesh,

    You can try using the following SDK example which shows how to implement custom open and save commands.
    If you have any problems with this example or some other concerns do not hesitate to contact us again.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft R3 2016 release webinar banner
Back to Top