# GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*">LoadDocument Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_System_IO_Stream_GrapeCity_Viewer_Common_DocumentFormat_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument(System.IO.Stream,GrapeCity.Viewer.Common.DocumentFormat)">LoadDocument(Stream, DocumentFormat)</h4>
<div class="markdown level1 summary"><p>Loads a document into the viewer from a provided stream, using the specified document format.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadDocument(Stream stream, DocumentFormat format)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a> that contains the document data to be loaded. The stream must be open and readable.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.DocumentFormat.html">DocumentFormat</a></td>
      <td><span class="parametername">format</span></td>
      <td><p>The format of the document contained in the stream, specified as a <a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.DocumentFormat.html">DocumentFormat</a>.
This parameter determines how the stream data is interpreted during the loading process.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_System_IO_Stream_GrapeCity_Viewer_Common_DocumentFormat__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method enables the loading of documents directly from a stream, facilitating scenarios where documents are stored in memory, in a database,
or retrieved from a network location, without the need for a physical file on disk.
Supported document formats are determined by the <a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.DocumentFormat.html">DocumentFormat</a> enumeration, which includes options
for various types of reports and documents supported by ActiveReports.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_System_IO_Stream_GrapeCity_Viewer_Common_DocumentFormat__examples">Examples</h5>
<p>Here is an example of using the <code>LoadDocument</code> method to load a report from a stream:</p>
<pre><code class="lang-csharp">using (var stream = new FileStream("path/to/report.rdlx", FileMode.Open))
{
    viewer.LoadDocument(stream, GrapeCity.Viewer.Common.DocumentFormat.Rdlx);
}</code></pre>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_System_String_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument(System.String)">LoadDocument(string)</h4>
<div class="markdown level1 summary"><p>Loads a document into the Viewer control from a specified file path.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadDocument(string filePath)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">filePath</span></td>
      <td><p>The path to the document file to be loaded. The file path can be absolute or relative to the application's current working directory.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method allows for loading documents from the file system into the Viewer control. It supports various document formats,
including but not limited to PDF, DOCX, and proprietary formats of ActiveReports.
Ensure that the file path points to a valid document file and that the application has the necessary permissions to read the file.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_System_String__examples">Examples</h5>
<p>Here is an example of using the <code>LoadDocument</code> method to load a report from a file:</p>
<pre><code class="lang-csharp">viewer.LoadDocument("path/to/report.rdlx");</code></pre>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_Viewer_Common_IDocumentLoader_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument(GrapeCity.Viewer.Common.IDocumentLoader)">LoadDocument(IDocumentLoader)</h4>
<div class="markdown level1 summary"><p>Loads a document into the Viewer control using the specified document loader.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadDocument(IDocumentLoader parameter)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.IDocumentLoader.html">IDocumentLoader</a></td>
      <td><span class="parametername">parameter</span></td>
      <td><p>The document loader used to load the document. The loader encapsulates the logic for loading documents from various sources,
such as a file, a stream, or other custom sources.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_Viewer_Common_IDocumentLoader__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method provides a flexible way to load documents into the Viewer control by abstracting the source of the document.
Implementations of <a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.IDocumentLoader.html">IDocumentLoader</a> can vary, allowing for documents to be loaded from different sources, including but not limited
to files, streams, and web services. The method delegates the loading process to the specified <a class="xref" href="../MESCIUS.ActiveReports.Viewer.Common/GrapeCity.Viewer.Common.IDocumentLoader.html">IDocumentLoader</a>,
which is responsible for opening the document and preparing it for viewing. It is important that the loader correctly implements the loading process
for the document's source and format. This approach allows for custom loading logic to be easily integrated into the Viewer control,
facilitating scenarios where documents need to be preprocessed or loaded in non-standard ways.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_Viewer_Common_IDocumentLoader__examples">Examples</h5>
<p>Implementing IDocumentLoader to Load a Document from a Stream:</p>
<pre><code class="lang-csharp">public class StreamDocumentLoader : IDocumentLoader
{
    public DocumentFormat DocumentFormat { get; private set; }

    public void Load(ILoadableFromFileAndStream obj)
    {
        // Assuming 'documentStream' is a Stream containing the document data
        Stream documentStream = new MemoryStream(File.ReadAllBytes("path/to/your/document.rdlx"));
        obj.LoadFromStream(documentStream);
        // Set the document format based on the stream content or other logic
        DocumentFormat = DocumentFormat.Rdlx;
    }
}
// Usage
// Assuming 'viewer' is an instance of the Viewer class and it has a method to accept IDocumentLoader
viewer.LoadDocument(new StreamDocumentLoader());</code></pre>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_Document_PageDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument(GrapeCity.ActiveReports.Document.PageDocument)">LoadDocument(PageDocument)</h4>
<div class="markdown level1 summary"><p>Loads the specified <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.PageDocument.html">PageDocument</a> into the Viewer control.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadDocument(PageDocument pageDocument)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.PageDocument.html">PageDocument</a></td>
      <td><span class="parametername">pageDocument</span></td>
      <td><p>The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.PageDocument.html">PageDocument</a> instance to be loaded into the Viewer.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_Document_PageDocument__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method enables the Viewer to display the content of a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.PageDocument.html">PageDocument</a>.
The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.PageDocument.html">PageDocument</a> should be properly initialized and contain the pages that you wish to display.
It's important to note that loading a new document will replace any previously loaded document in the Viewer.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_Document_PageDocument__examples">Examples</h5>
<p>Here is an example of creating a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.PageDocument.html">PageDocument</a> and loading it into the Viewer:</p>
<pre><code class="lang-csharp">// Assuming 'viewer' is an instance of the Viewer control
var pageReport = new PageReport();
pageReport.Load(new FileInfo(@"path/to/report.rdlx"));
var pageDocument = pageReport.Document;
viewer.LoadDocument(pageDocument);</code></pre>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_PageReport_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument(GrapeCity.ActiveReports.PageReport)">LoadDocument(PageReport)</h4>
<div class="markdown level1 summary"><p>Loads the specified <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html">PageReport</a> into the Viewer control.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadDocument(PageReport pageReport)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html">PageReport</a></td>
      <td><span class="parametername">pageReport</span></td>
      <td><p>The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html">PageReport</a> instance to be loaded into the Viewer.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_PageReport__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method allows the Viewer to display the content of a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html">PageReport</a>, which is a report designed in the Page Report format.
The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html">PageReport</a> encapsulates the report definition along with its data sources, parameters, and layout information.
The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html">PageReport</a> should be properly initialized with its definition (usually a .rdlx file) and any necessary data connections.
It's important to note that loading a new report will replace any previously loaded document or report in the Viewer.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_PageReport__examples">Examples</h5>
<p>Here is an example of loading a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.PageReport.html">PageReport</a> into the Viewer:</p>
<pre><code class="lang-csharp">// Assuming 'viewer' is an instance of the Viewer control and 'reportPath' is the path to the .rdlx file
PageReport pageReport = new PageReport(new FileInfo(reportPath));
viewer.LoadDocument(pageReport);</code></pre>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_SectionReport_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument(GrapeCity.ActiveReports.SectionReport)">LoadDocument(SectionReport)</h4>
<div class="markdown level1 summary"><p>Loads the specified <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.SectionReport.html">SectionReport</a> into the Viewer control.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadDocument(SectionReport report)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.SectionReport.html">SectionReport</a></td>
      <td><span class="parametername">report</span></td>
      <td><p>The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.SectionReport.html">SectionReport</a> instance to be loaded into the Viewer. This report represents a document structured in sections,
which can include headers, footers, and detail sections, each potentially containing data-bound elements, static content, or a combination of both.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_SectionReport__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method enables the Viewer to display the content of a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.SectionReport.html">SectionReport</a>, which is a report designed using the Section-based approach.
The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.SectionReport.html">SectionReport</a> should be properly initialized with its layout definition and any necessary data connections or scripting logic.
It's important to note that loading a new report will replace any previously loaded document or report in the Viewer.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_SectionReport__examples">Examples</h5>
<p>Here is an example of loading a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.SectionReport.html">SectionReport</a> into the Viewer:</p>
<pre><code class="lang-csharp">// Assuming 'viewer' is an instance of the Viewer control and 'reportPath' is the path to the .rpx file
var report = new SectionReport();
report.LoadLayout(XmlReader.Create(reportPath));
report.Document.Printer.PrinterName = string.Empty;
viewer.LoadDocument(report);</code></pre>



<a id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument*"></a>
<h4 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_Document_SectionDocument_" data-uid="GrapeCity.ActiveReports.Viewer.Win.Viewer.LoadDocument(GrapeCity.ActiveReports.Document.SectionDocument)">LoadDocument(SectionDocument)</h4>
<div class="markdown level1 summary"><p>Loads the specified <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.SectionDocument.html">SectionDocument</a> into the Viewer control.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void LoadDocument(SectionDocument document)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.SectionDocument.html">SectionDocument</a></td>
      <td><span class="parametername">document</span></td>
      <td><p>The <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.SectionDocument.html">SectionDocument</a> instance to be loaded into the Viewer.
This document represents a compiled version of a section report, which is ready to be rendered and viewed.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_Document_SectionDocument__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method enables the Viewer to display the content of a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.SectionDocument.html">SectionDocument</a>, which is essentially a compiled section report.
It's important to note that loading a new document will replace any previously loaded document or report in the Viewer.</p>
</div>
<h5 id="GrapeCity_ActiveReports_Viewer_Win_Viewer_LoadDocument_GrapeCity_ActiveReports_Document_SectionDocument__examples">Examples</h5>
<p>Here is an example of loading a <a class="xref" href="../MESCIUS.ActiveReports/GrapeCity.ActiveReports.Document.SectionDocument.html">SectionDocument</a> into the Viewer:</p>
<pre><code class="lang-csharp">// Assuming 'viewer' is an instance of the Viewer control
var sectionDocument = new SectionDocument("SectionDocument1");
sectionDocument.Pages.Add(new Document.Section.Page());
Viewer.LoadDocument(sectionDocument);</code></pre>

</div>
