[]
Loads a document into the viewer from a provided stream, using the specified document format.
public void LoadDocument(Stream stream, DocumentFormat format)
Type | Name | Description |
---|---|---|
Stream | stream | The Stream that contains the document data to be loaded. The stream must be open and readable. |
DocumentFormat | format | The format of the document contained in the stream, specified as a DocumentFormat. This parameter determines how the stream data is interpreted during the loading process. |
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 DocumentFormat enumeration, which includes options for various types of reports and documents supported by ActiveReports.
Here is an example of using the LoadDocument
method to load a report from a stream:
using (var stream = new FileStream("path/to/report.rdlx", FileMode.Open))
{
viewer.LoadDocument(stream, GrapeCity.Viewer.Common.DocumentFormat.Rdlx);
}
Loads a document into the Viewer control from a specified file path.
public void LoadDocument(string filePath)
Type | Name | Description |
---|---|---|
string | filePath | The path to the document file to be loaded. The file path can be absolute or relative to the application's current working directory. |
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.
Here is an example of using the LoadDocument
method to load a report from a file:
viewer.LoadDocument("path/to/report.rdlx");
Loads a document into the Viewer control using the specified document loader.
public void LoadDocument(IDocumentLoader parameter)
Type | Name | Description |
---|---|---|
IDocumentLoader | parameter | 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. |
This method provides a flexible way to load documents into the Viewer control by abstracting the source of the document. Implementations of IDocumentLoader 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 IDocumentLoader, 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.
Implementing IDocumentLoader to Load a Document from a Stream:
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());
Loads the specified PageDocument into the Viewer control.
public void LoadDocument(PageDocument pageDocument)
Type | Name | Description |
---|---|---|
PageDocument | pageDocument | The PageDocument instance to be loaded into the Viewer. |
This method enables the Viewer to display the content of a PageDocument. The PageDocument 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.
Here is an example of creating a PageDocument and loading it into the Viewer:
// 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);
Loads the specified PageReport into the Viewer control.
public void LoadDocument(PageReport pageReport)
Type | Name | Description |
---|---|---|
PageReport | pageReport | The PageReport instance to be loaded into the Viewer. |
This method allows the Viewer to display the content of a PageReport, which is a report designed in the Page Report format. The PageReport encapsulates the report definition along with its data sources, parameters, and layout information. The PageReport 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.
Here is an example of loading a PageReport into the Viewer:
// 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);
Loads the specified SectionReport into the Viewer control.
public void LoadDocument(SectionReport report)
Type | Name | Description |
---|---|---|
SectionReport | report | The SectionReport 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. |
This method enables the Viewer to display the content of a SectionReport, which is a report designed using the Section-based approach. The SectionReport 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.
Here is an example of loading a SectionReport into the Viewer:
// 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);
Loads the specified SectionDocument into the Viewer control.
public void LoadDocument(SectionDocument document)
Type | Name | Description |
---|---|---|
SectionDocument | document | The SectionDocument 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. |
This method enables the Viewer to display the content of a SectionDocument, 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.
Here is an example of loading a SectionDocument into the Viewer:
// Assuming 'viewer' is an instance of the Viewer control
var sectionDocument = new SectionDocument("SectionDocument1");
sectionDocument.Pages.Add(new Document.Section.Page());
Viewer.LoadDocument(sectionDocument);