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

Format Not Supported Errors

3 Answers 93 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 21 Feb 2013, 02:40 AM
I am trying to create a standard document viewer for a richtextbox so that i can load files stored in my database and load them dynamically into my control

These documents are limited to pdf/word/images.

For an image i load it into a imageeditor fine.

For documents i get unsupported errors when using provider.Import ();

Running

DocumentFormatProvidersManager.GetSupportedExtensions();

only gives me txt and pdf.

 

IDocumentFormatProvider provider = new PdfFormatProvider();

 

if (provider != null)

{

doc = provider.Import(stream);

}

Copying the telerik examples gives me the same problems. Any examples of opening pdf/word documents into a RadDocument for a RichText control ?

3 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 25 Feb 2013, 01:30 PM
Hello Ian,

The DocumentFormatProvidersManager.GetSupportedExtensions() method returns only the supported extensions. As the format providers responsible for import/export are shipped in separate assemblies, if the respective assemblies are not added to your project, the method will not return those extensions.

The documentation regarding Import/Export is located here. You can find information on the supported formats (note that PDF is not a supported import format), required assemblies as well as sample code.

On a side note, if you wish to display PDF files, you can try RadPdfViewer which is intended for that. I suggest you check the online demo here and the documentation of the control here.

Let us know if you need further assistance.
 
Kind regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Ian
Top achievements
Rank 1
answered on 26 Feb 2013, 04:36 AM
Thanks but now i am having problems with RadPdfViewer. See my code below.

I have a memorystream which i want to load. pdf.Document is always null and setting pdfeditor.documentsource gives me nothing also.

Any ideas ?

using

 

 

(Stream s = new MemoryStream(t.FactOLE))

{

 

this.imageGrid.Visibility = Visibility.Collapsed;

 

this.pdfGrid.Visibility = Visibility.Visible;

 

PdfDocumentSource pdf = new PdfDocumentSource(s);

 

this.pdfEditor.Document = pdf.Document;

}

0
Petya
Telerik team
answered on 28 Feb 2013, 05:18 PM
Hello Ian,

The proper syntax you should use is 
PdfDocumentSource pdf = new PdfDocumentSource(s);
 
this.pdfViewer.DocumentSource = pdf;

However, there are other reasons that may cause similar issues, one of which is if the document has many null bytes at the end. RadPdfViewer starts to read the PDF files from their end trying to locate the %%EOF marker. If there are such null bytes, it cannot be found and the file cannot be loaded.

If none of these help, please get back to us with some additional details on your setup.

Regards,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Ian
Top achievements
Rank 1
Answers by
Petya
Telerik team
Ian
Top achievements
Rank 1
Share this question
or