Creating and Viewing Acrobat file using MemoryStream
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?
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.
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.
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.
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,
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.