For a long time, you have been using ComponentOne reporting and document objects like FlexReport, C1PdfDocumentSource, and C1SSRSDocumentSource. But have you ever wondered how these objects are managed and what the underlying source that handles them in a uniform manner is?
C1Document (or C1.Win.C1Document) library is the underlying framework that works behind these objects. This helps put forward C1Document's features and the document objects based on it. Whether it's loading a PDF in a viewer, adding features to FlexReport and loading it in a viewer, or loading SSRS reports and showcasing their features in a viewer, C1Document is the source that is managing these functions in the background.
C1DocumentSource is the abstract base class for components that are used to build instances of C1Document from various data: C1FlexReport builds documents from report definitions and data sources, C1PdfDocumentSource from PDF files, and C1SSRSDocumentSource from SSRS reports. Controls that consume C1Document objects (e.g. C1FlexViewer) actually connect to instances of C1DocumentSource type rather than to C1Document.
Here are some key features of C1Document (please note that these features describe the technical architecture of reports and documents in the background):
- Cross-platform: supports reports and documents in Winforms, WPF, and UWP platforms with minimal code differences.
- Complete framework to create reports and documents.
- Provides infrastructure for asynchronous document generation.
- Supports the notion of parameters used in C1FlexReport and SSRS documents.
- Supports text searching in documents.
- Provides export filters for reports and document objects to export them to various major export formats.
Please note that C1Document can't be used directly as a document or report, but the objects derived from it can be used to create reports and documents. The following codes show how the derived objects are connected to C1Document.
How to use C1Document to load and view PDF file
You can use the C1PDFDocumentSource component of C1Document to load a PDF file. This PDF component can read, print, and export your PDF documents without any third party PDF reader or software. It also acts as a key component to load and view your PDFs in C1FlexViewer.
You can load a PDF file using C1Document with the following code:
C1.Win.C1Document.C1PdfDocumentSource pdfdoc=new C1.Win.C1Document.C1PdfDocumentSource(); pdfdoc.LoadFromFile(@"..\..\DefaultDocument.pdf"); //Assign the PDFDocumentSource to FlexViewer, to view the PDF File c1FlexViewer.DocumentSource=pdfdoc;
To learn more about key features of this component, why you should use it, and different use cases where it can help, please visit this blog. need to link to blog
How to use C1Document to load and view a SSRS Document
C1SSRSDocumentSource helps to load SSRS reports in FlexViewer and supports other SSRS features. The following features in SSRS reports are supported in C1SSRSDocumentSource:
- Drill down, drill through
Here's how you load a SSRS document in FlexViewer using C1Document:
C1.Win.C1Document.C1SSRSDocumentSource ssrsdoc=new C1.Win.C1Document.C1SSRSDocumentSource(); ssrsdoc.DocumentLocation =new SSRSReportLocation("<ssrsUrl>", "AdventureWorks/Product Catalog" ); ssrsdoc.Credential =new NetworkCredential("ssrsUsername","ssrsPassword", "ssrsDomain"); c1FlexViewer.DocumentSource=ssrsdoc;
You can find samples on PdfDocumentSource and SSRSDocumentSource at the following locations after installing C1Studio installer for WinForms, WPF, and UWP. These samples will be available in a week from now with 2017v2 Release.
Winforms - C:\Users\<User>\Documents\ComponentOneSamples\Winforms\C1Document\CS<(orVB)>\
WPF - C:\Users\<User>\Documents\ComponentOneSamples\WPF\C1.WPF.Document\CS<(orVB)>\
UWP - C:\Users\<User>\Documents\ComponentOneSamples\WPF\C1.WPF.Document\CS<(orVB)>\
Please visit C1Document documentation that will be released in a week from now for more information about C1Document and its derived components.