Document Library for WPF | ComponentOne
PdfDocumentSource for WPF / Features / Load PDF
In This Topic
    Load PDF
    In This Topic

    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.

    pds.LoadFromFile("..\..\DefaultDocument.pdf")
    
    pds.LoadFromFile(@"..\..\DefaultDocument.pdf");
    

    To load PDF from stream

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

    Dim pds As New C1PdfDocumentSource()
    'Load report from stream
    Dim asm As Assembly = [GetType]().Assembly
    Using stream As Stream = asm.GetManifestResourceStream _
            ("PDFDocumentSource_LoadFromStream_VB.Resources.DefaultDocument.pdf")
      pds.LoadFromStream(stream)
    End Using
    
    C1PdfDocumentSource pds = new C1PdfDocumentSource();
    //Load report from stream
    Assembly asm = GetType().Assembly;
    using (Stream stream = asm.GetManifestResourceStream
      (@"PDFDocumentSource_LoadfromStream.Resources.DefaultDocument.pdf"))
        pds.LoadFromStream(stream);
    
    See Also