Skip to main content Skip to footer

Display a PDF in C1Book

Download the latest update to Studio for Silverlight or Studio for WPF to get the lastest C1PdfViewer control. This control has had many enhancements including support for compressed object streams and improved font and image handling.

In addition to all the internal enhancements, you can now get the pdf content in your code with the new GetPages method. This method returns a copy of the FrameworkElements representing each page in a loaded PDF file. So now, not only can you read the document content in code, but you can change how the user views a PDF file.

For instance, now you can take the pages and put them in a C1Book control.

var dlg = new OpenFileDialog();  
dlg.Filter = "Pdf|*.pdf";  
if (dlg.ShowDialog().Value)  
{  
    using (var s = dlg.File.OpenRead())  
    {  
        var pdfviewer = new C1.Silverlight.PdfViewer.C1PdfViewer();  
        pdfviewer.LoadDocument(s);  

        // fill c1book with pdf pages  
        c1Book1.Items.Clear();  
        foreach (var page in pdfviewer.GetPages())  
        {  
            c1Book1.Items.Add(page);  
        }  
        c1Book1.CurrentPage = 0;  
    }  
}

It's that simple! Download a sample below.

ComponentOne Product Manager Greg Lutz

Greg Lutz

comments powered by Disqus