Read and view a file from Azure in .NET

Hi,
I am a new user of your libraries and I am doing a demo for a client.
I downloaded the GroupDocs.Viewer library version 20.11.0 via NuGet (VS 2017), there and I’m trying to view a file (in this case .docx reading from Azure).
Testing and debugging locally, I get the following error:

GroupDocs.Viewer.Exceptions.GroupDocsViewerException
HResult=0x80131500
Message=Accesso al percorso ‘C:\Program Files (x86)\IIS Express\output.pdf’ negato.
Source=GroupDocs.Viewer
StackTrace:
at ​ . (Int32[] , IFileStreamFactory )
at .(Int32[] , PdfViewOptions , )
at . (Func2 , ViewOptions , Int32[] ) at . (Func2 , ViewOptions )
at GroupDocs.Viewer.Viewer.View(ViewOptions options)
at DocMaster.Page.Preview.Page_Load(Object sender, EventArgs e) in C:\Source\Repos\Silversea\Silversea-DocumentMaster\DocMaster\Page\Preview.aspx.cs:line 92

Can you help me solve it?

In the attachment the .cs file
Preview.aspx.cs.zip (1.2 KB)

Can you help me solve it?

Bye
Davide

1 Like

@LBA_Development

Do you face this issue for only Word files and other file formats work?

I have tried with other file types ( .pdf, .pptx, .jpg ) but the error is still the same.

Bye
Davide

1 Like

@LBA_Development

We’re investigating this scenario. Your investigation ticket ID is VIEWERNET-2948. We’ll let you know if any further details are required.

@LBA_Development

We’ve an update on VIEWERNET-2948. Your code is fine. However, it seems that the app doesn’t have access to the folder. When rendering any file, the default view options e.g. new PdfViewOptions() is saving output file to the current directory. In this case current directory is 'C:\Program Files (x86)\IIS Express', and error says that the application doesn’t have access to this folder. There are few options:

  • Try running Visual Studio as Administrator
  • Set output path in PdfViewOptions to some folder that is accessible by the application

Have a look at following code:

using (Viewer viewer = new Viewer(streamFactory))
{
  PdfViewOptions viewOptions = new PdfViewOptions(@"D:\output\output.pdf");
  viewer.View(viewOptions);
}

Let us know if it helps.

Hi,
I tried as Administrator and I don’thave the error, but the page that appears is completely blank.
I tried to change File ( .pdf and .pptx) it always remains blank.
I also tried to put a path in the PdfPreviewoption, but nothing changes.

2020-12-04 08_56_22-localhost_44368_page_Preview.aspx_DocId=58&Mode=I.png (6.9 KB)

What can I still do?

Bye
Da vide

1 Like

@LBA_Development

Could you please confirm if you are getting output/resultant PDF file in the output directory? If yes, please tell, how you are rendering/displaying that PDF in browser?
The core feature of the API is just to convert the source file into PDF, HTML or Image. Later, you have to render the resultant file(s) in browser using custom logic/code.

Hi,
I confirm that the file is generated correctly in the output folder.

I did not realize that the rendering part was left to a custom logic. No problem.

Question: Can the rendering function directly return a byte[] or stream of the generated file (.PDF in this case)? So to integrate everything into a C# handler?

Bye
Davide

1 Like

@LBA_Development

Yes, you could save the result in MemoryStream. For example, have a look at this code/proejct.