PDFOne .NET
Powerful all-in-one PDF library for .NET
Compatibility
VS 2005/2008/2010/2012/2013

Display PDF without saving file to disk in WinForms and ASP.NET

Load from byte array or stream and discard after use.

It is bizarre how much time and expense is devoted to create documents and then limiting access to it. An oft-asked question on stackoverflow.com and other forums is how to display a document without saving to disk.

If it is a "Windows Forms Application" (now called "Classic Desktop"), then a WinForms document viewer that can load from a byte array or a stream would do.

With the PDF viewer in PDFOne .NET, the code can look like this:

try {
  FileStream oFS = File.OpenRead(@"top-secret.pdf");
  byte[] baPDF = new byte[oFS.Length];

  oFS.Read(baPDF, 0, Convert.ToInt32(oFS.Length));

  pdfViewer1.LoadDocument(baPDF);
} catch (Exception err) {
  MessageBox.Show(err.Message);
}

When the document is available or is generated on the server, then developers want the documents to be displayed in a browser but not be downloadable, at least not as the original PDF file. In such cases, the download button in the toolbar of the PDF "Web" viewer component needs to be disabled. Similarly, the print function can also be disabled.

PDFViewer1.ToolBar.SavePage.Visible = false;
PDFViewer1.ToolBar.PrintPage.Visible = false;
PDFViewer1.LoadDocument(Server.MapPath(".") + "\\App_Data\\secret-decoder.pdf");

---o0O0o---

Our .NET Developer Tools
Gnostice Document Studio .NET

Multi-format document-processing component suite for .NET developers.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
Gnostice Document Studio Java

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved.