Show PDF in RadPdfViewer from URL in WinForm

雨燕双飞 提交于 2019-12-14 04:23:13

问题


I'm using RadPdfViewer first time in my WinForm application. I want to load pdf from url (e.g. http://10.70.0.60/PDF/sample.pdf ).

Its working with local file but not with website url of PDF file, I have mentioned in example. Kindly please suggest me how I load PDF from url in RadPdfViewer Control.Kindly let me know if any other detail required.

Thanks in advance


回答1:


I have solved the issue by my self. Hope this answer will save next person time. Below code is working fine for me.

using (WebClient client = new WebClient())
        {
            using (Stream ms = new MemoryStream(client.DownloadData("http://10.70.0.60/PDF/sample.pdf")))
            {
                MemoryStream mStream = new MemoryStream();
                mStream.SetLength(ms.Length);
                ms.Read(mStream.GetBuffer(), 0, (int)ms.Length);
                this.radPdfViewer1.LoadDocument(mStream);                    
            }
        }



回答2:


You can set Documentsource as shows, Wroked for me

 PDFViewer.DocumentSource = new PdfDocumentSource(new Uri(@"YOUR PATH");


来源:https://stackoverflow.com/questions/32368271/show-pdf-in-radpdfviewer-from-url-in-winform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!