More in this section

Forums / General Discussions / Convert doc to PDF

Convert doc to PDF

3 posts, 1 answered
  1. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    28 Mar 2011
    Link to this post
    Hi,

    How easy would it be to be able to
    convert a word document into a PDF
    document during the upload into the library?

    Can it be easily integrated within Sitefinity?

    ----

    What I am trying to achieve is to display a Office Document (Word,
    Excel, Power Point, etc) inside a Web Browser. In XP was able to do that
    but in Windows 7 I can't. Is there a RAD Control that would display 
    a document embedded in the Browser. I do not want it opening in a separate 
    window.

    Thanks,
    Andrei 
  2. Milena
    Milena avatar
    75 posts
    Registered:
    27 Sep 2017
    01 Apr 2011
    Link to this post
    Hello Andrei,

    You can create a custom type that inherits from OpenAccessLibrariesProvider.
     
    Please, make sure that the provider is properly registered inside Sitefinity/Administration/Settings/Advanced/ Libraries/Providers configuration.After you register the provider, please restart the application.

    In your custom type you have to override virtual method UploadDataOnly responsible for uploading binary data of media content items(documents, videos and images) and implement your custom logic for converting to .pdf before upload the document.

               /// <summary>
           /// Uploads only the binary data of an media content item.
           /// </summary>
           /// <param name="content">The content.</param>
           /// <param name="source">The source.</param>
           protected virtual void UploadDataOnly(MediaContent content, Stream source)
           {
               source.Position = 0;
               var buffer = new byte[content.ChunkSize];
               int bytesRead = buffer.Length;
               using (Stream destinaion = this.GetContentStream(content))
               {
                   while (bytesRead == buffer.Length)
                   {
                       bytesRead = source.Read(buffer, 0, buffer.Length);
                       if (bytesRead > 0)
                           destinaion.Write(buffer, 0, bytesRead);
                   }
               }
           }

    All the best,
    Milena
    the Telerik team
    Answered
  3. Andrei
    Andrei avatar
    553 posts
    Registered:
    27 Nov 2008
    01 Apr 2011
    Link to this post
    Thanks Milena,

    I will give it a very good think. The desired result would be
    to manage to display office documents in browser, but if
    that won't work then your solution would be the favourite.

    Thanks again,
    Andrei
3 posts, 1 answered