ComponentOne Document Library for WinForms
Load PDF
PdfDocumentSource for WinForms > Features > Load PDF

PdfDocumentSource allows you to load a PDF in FlexViewer control using two methods, LoadFromFile and LoadFromStream, of C1PdfDocumentSource class. The LoadFromFile method loads PDF from the source file and the LoadFromstream method loads a PDf from source stream.

To load PDF from file

The following code uses the LoadFromFile method to load a PDF from source file.

C1PdfDocumentSource1.LoadFromFile("..\..\DefaultDocument.pdf")
c1PdfDocumentSource1.LoadFromFile(@"..\..\DefaultDocument.pdf");

To load PDF from stream

The following code uses the LoadFromStream method to load a PDF from source stream.

'Load report from stream
Dim asm As Assembly = [GetType]().Assembly
Using stream As Stream = asm.GetManifestResourceStream(
             "LoadPDFFromStream_VB.Resources.DefaultDocument.pdf")
    C1PdfDocumentSource1.LoadFromStream(stream)
End Using
//Load report from stream
Assembly asm = GetType().Assembly;
using (Stream stream =
asm.GetManifestResourceStream(@"LoadPDFfromStream.Resources.DefaultDocument.pdf"))
c1PdfDocumentSource1.LoadFromStream(stream);
See Also