private void RadButton_Click(object sender, RoutedEventArgs e) { var fileContent = string.Empty; RadOpenFileDialog openFileDialog = new RadOpenFileDialog() { Filter = "|PDF Files (*.pdf)|*.pdf", FilterIndex = 1, }; openFileDialog.ShowDialog(); if (openFileDialog.DialogResult == true) { try { Stream fileStream = openFileDialog.OpenFile(); ConvertPDF(fileStream); MemoryStream ms = new MemoryStream(PDFBodyBytes); EmptyContent.Visibility = Visibility.Collapsed; PDFBody = new PdfDocumentSource(ms); pdfViewer.DocumentSource = new PdfDocumentSource(ms); } catch { } } }
public override void Execute(object parameter) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "PDF Files (*.pdf)|*.pdf"; if (dialog.ShowDialog() == true) { #if SILVERLIGHT FileStream str = dialog.File.OpenRead(); #endif #if WPF Stream str = dialog.OpenFile(); #endif str.CopyTo(stream); str.Flush(); str.Seek(0, SeekOrigin.Begin); stream.Flush(); PdfDocumentSource source = new PdfDocumentSource(str, FormatProviderSettings.ReadAllAtOnce); source.Loaded += (s, e) => { str.Close(); }; this.Viewer.DocumentSource = source; } }
public PdfFileViewModel(string displayName, byte[] pdfData) { DisplayName = displayName; PdfDocument = new PdfDocumentSource(new MemoryStream(pdfData)); DialogWidth = IoC.Get<IShell>().CurrentWidth - 50; DialogHeight = IoC.Get<IShell>().CurrentHeight - 120; }
private void SetPdfViewerDataSource(DocumentVersion documentVersion) { try { CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint); cmsWebServiceClient.GetDocumentVersionContentCompleted += (s1, e1) => { //mView.busyIndicator.IsBusy = false; if (!e1.Result.HasErrors) { byte[] bytes = e1.Result.EntityResult; if (bytes.Length == 0) { return; } MemoryStream ms = new MemoryStream(bytes); FixedDocumentStreamSource fdss = new PdfDocumentSource(ms); mView.pdfViewer.DocumentSource = fdss; mView.pdfViewer.Visibility=Visibility.Visible; } else { mView.WarningPopup.Show(Utils.BuildValidationResultFromServerErrors(MESSAGE, e1.Result.ServerErrorMessages)); } }; cmsWebServiceClient.GetDocumentVersionContentAsync(documentVersion); } catch (Exception ex) { //mView.busyIndicator.IsBusy = false; mView.WarningPopup.Show(Utils.BuildValidationResultFromServerErrors(MESSAGE, new List<string> { ex.Message })); } }
public override void Execute(object parameter) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "PDF Files (*.pdf)|*.pdf"; if (dialog.ShowDialog() == true) { #if SILVERLIGHT FileStream str = dialog.File.OpenRead(); #elif WPF Stream str = dialog.OpenFile(); #endif str.CopyTo(stream); str.Flush(); str.Seek(0, SeekOrigin.Begin); stream.Flush(); PdfDocumentSource source = new PdfDocumentSource(str, FormatProviderSettings.ReadOnDemand); source.Loaded += (s, e) => { str.Close(); }; this.Viewer.DocumentSource = source; } }