Render Document viewer in MVC view Page

I have try yo render the document viewer in .net mvc view page but I couldn’t render the same.

it will not given error but it should be view in .net mvc.

Note: I have used GroupDocs.viewer.Dll

1 Like

@passion.avp

Please note that the core API feature is to convert the source file to PDF, HTML or Image file format and save it to the directory or return result in stream. Later, it’s up to you to render the converted file in browser or any application (e.g. Windows form).
For example, have a look at the following code:

string outputDirectory = "output directory";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.png");
 using (Viewer viewer = new Viewer("sample.docx"))
 {
       PngViewOptions options = new PngViewOptions(pageFilePathFormat);
       viewer.View(options);
}

Now, in the this code, API is taking a source file as input (Word file), converting it to PNG and saving to output directory. Next, you have to render the output PNG in browser.
Have a look at this sample ASP.NET MVC Document Viewer application.

Thank you for your response @Atir_Tahir, I am working on .Net framework 4.7.2 so given code is not working on the same .net framework so could you please give me the solution for same framework.

Error : Could not load file or assembly ‘System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I need this type of viewer on browser
image.png (67.7 KB)

1 Like

@passion.avp

We couldn’t reproduce this issue/error at our end. Have a look at this screencast.zip (2.4 MB).

Have a look at the supported .NET frameworks or the minimum system requirements. Could you please share your application using that we could reproduce this issue?

Ok Let me check from my end and if i need to open png/pdf in viewer in browser then what should I have do?

@passion.avp

You just have to pass that file/format to Viewer. Have a look at this video.

I need other feature on browser when view any document,feature is like zoomout, zoomin and download,in your video there is no such feature

@Atir_Tahir,I need to implement urgently because I have purchased $999 license 1 month ago and stucked on above implementation.

@passion.avp

That application demonstrates the basic or the core API functionality.

However, we do have an open-source ASP.NET MVC project that gives you following (but not limited to) features:

  • Download documents
  • Upload documents
  • Print document
  • Rotate pages
  • Zoom in/out documents without quality loss in HTML mode
  • Thumbnails
  • Smooth page navigation

Have a look at this video demo. Download this project here.

I couldn’t implement given project as per my requirement,I don’t want sample project but I need implement in existing project.

Please check below requirement

  1. I will only give jpg,png,doc,docx,xlsx,xls,pdf document url path
  2. as per given path document should render in view page.
  3. Please give me straight forward solution to implement document view with zoomIn,
    zoomOut, download feature.

Note: I don’t want to give selection to user select the document from tree

@passion.avp

As you know that the API is UI-Agnostic. There are no such (e.g. zoom in, download) built-in features. However, they could be added in the front-end project using JS. For example, below code could be used to zoom in and out:

function zoomIn()
{
  var Page = document.getElementById('Body');
  var zoom = parseInt(Page.style.zoom) + 5 +'%'
  Page.style.zoom = zoom;
  return false;
}

function zoomOut()
{
  var Page = document.getElementById('Body');
  var zoom = parseInt(Page.style.zoom) - 5 +'%'
  Page.style.zoom = zoom;
  return false;
}

In order to make you a working solution with such a features, we need time. Please note that all free support issues are handled at first come first served basis. So, we couldn’t commit any ETA at the moment.