[SOLVED] PdfViewer

Answered Closed
0
0

Hi,

Creating and Viewing Acrobat file using MemoryStream

  1. After creating the file and used pdfViewer.PdfStream = <memorystream name> or pdfViewer.PdfSource = <full path of the file when saved to disk>, I don’t see anything in the viewer and get “Invalid Session” message.
  2. Close the browser and re-run the project. Since the file is already on disk, don’t recreate and just view the pdf file using pdfViewer.PdfSource = <full path of the file when saved to disk>. It works OK.

What am I missing or doing wrong in #1? Is it possible to view the memorystream contents directly in to PdfViewer without saving it to disk?

Thanks.

 

Attachment
  • You must to post comments
Best Answer
0
0

Please try the latest update. It has a number of fixes including handling of the source for the FlashViewer and the PdfViewer. It’s not linked with the issues yet.

  • You must to post comments
0
0

Hi Alex,

I have played a bit with http://onlyoffice.org with the intention of integrating it with wisej. It’s an amazing free open source and commercial product. It seems to work better than google docs and microsoft’s online office.

I left it on the todo list for now. But it can certainly be used with wisej.

My preference would be to also integrate the server and let wisej serve the documents. But for that we will have to make some kind of OEM agreement.

To convert open office docs to pdf look for doc4j  port to .NET.

HTH

Best,

Luca

 

  • You must to post comments
0
0

Hi guys,

This is not related with the PdfViewer, but I thought it would be worth asking such a knowledgeable community! Do you happen to know of any utility that can convert Office documents (.docx, .xlsx and possibly older ones, .doc/.xls) to pdf? The utility should be installed on the server, should not need Office installed on the server and have a reasonable price… I know of various commercial products, but they are ridiculously expensive.

Alternatively, any way to show office documents without converting them and without having the user download them and open them with their own installed Office? Anybody has tried the “ASP.NET Web Forms DocuVieware Lite” which claims to be a lite/free version of the “universal” same-named (without the “Lite”) document viewer (it does not show Excel though). And, Luca, if such a WebForms control could be integrated in Wisej ?

Just looking for ideas during the summer holidays!

All the best,
Alex

  • You must to post comments
0
0

Hi Luca,

The error message in JSON format is now gone.

Above code snippet works and thanks. But it presupposes the there is an existing, pre-saved pdf file. It opens the file, puts it into a memorystream then display the contents in pdfviewer.

It may no be clear of what I intend to do but  I need to  programmatically create a pdf file using itextsharp and memorystream and view it directly in pdfwiever without first saving it into a disk.

But anyway, I was already able to resolve it based on the above code snippet.

Thanks

  • You must to post comments
0
0

Hi Cris,

The property PdfSource takes in either an external URL (the source should have CORS allowed) or a local file. The local file must be a file that can be server by the server, not a file anywhere on the disk. We should throw a clear exception when the file contains a full path. Try to place the file under the project and selected it with the file picker. It should work.

I also tried assigning the PdfStream in the form’s OnLoad event and it seems to work.

var file = new FileStream(@"C:\Users\Luca\Downloads\Wisej-Datasheet-V2.1.pdf", FileMode.Open, FileAccess.Read);
 var reader = new BinaryReader(file);
 var buffer = reader.ReadBytes((int)file.Length);
 var mem = new MemoryStream(buffer);

this.pdfViewer1.PdfStream = mem;

The JSON you see is the description  of the exception that is displayed by the pdf viewer object. It’s clearly a bug.

HTH

Best,

Luca

 

  • Luca (ITG)
    Actually I’m wrong about the local file. It takes any path.
  • preecha wanlor
    Then click Show pdf file again Can’t access file How to Fix it S ‘The process cannot access the file because it is being used by another process.’
  • preecha wanlor
    var file = new FileStream(filename, FileMode.Open, FileAccess.Read); var reader = new BinaryReader(file); var buffer = reader.ReadBytes((int)file.Length); var mem = new MemoryStream(buffer); this.pdfViewer1.PdfStream = mem; file.Close(); *** Sorry to ask you quickly,i am done
  • You must to post comments
0
0

Hi,

I intentionally deleted the pdf file created, then tried to view the file without checking it’s existence but within a try-catch-block. See the attached image for what I got. I expected the the code in the catch block will be executed.

Thanks.

 

Attachment
  • You must to post comments
Showing 6 results