Format Not Supported Errors

4 posts, 0 answers
  1. Ian
    Ian avatar
    23 posts
    Member since:
    Jun 2011

    Posted 20 Feb 2013 Link to this post

    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 ?

  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 25 Feb 2013 Link to this post

    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.

  3. DevCraft banner
  4. Ian
    Ian avatar
    23 posts
    Member since:
    Jun 2011

    Posted 25 Feb 2013 Link to this post

    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;

    }

  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 28 Feb 2013 Link to this post

    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.

Back to Top