我正在尝试使用Telerik的RadPDFViewer,但我遇到了一个问题。我似乎无法让IT加载任何文档。我试图从斑点从Azure存储中加载流,我已正确连接到该斑点,但是我似乎无法让PDF查看器显示PDF。
如果有人可以将我指向正确的方向,这将非常感谢
这是我从斑点获取PDF的代码:
public byte[] PreviewBlob(string blobUri)
{
//Create the credentials to save to Azure Blob
StorageCredentials credentials = new StorageCredentials("pdmacstorage", "IhaveThisEnteredCorrectlyNoWorries");
//Set the top level container for the file
folderPath = "job-file";
//Connect to Azure using the above credentials
CloudBlobClient client = new CloudBlobClient(new Uri("https://pdmacstorage.blob.core.windows.net/"), credentials);
//Get refrence to the container
CloudBlobContainer container = client.GetContainerReference(folderPath);
//Get refrence to the blob
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobUri);
using(var memoryStream = new MemoryStream())
{
blockBlob.DownloadToStream(memoryStream);
return memoryStream.ToArray();
}
}
这是我从另一种形式称呼它的代码:
private Stream callPDFPreivew()
{
//Connection to PDData AzureJobFileUploader
AzureJobFileUploader azureFileUpload = new AzureJobFileUploader();
using(var memoryStreamFromByte = new MemoryStream(azureFileUpload.PreviewBlob(file.Name)))
{
return memoryStreamFromByte;
}
}
最后,这就是我调用该方法的方式,我将其放置在选择中。
pdfViewer.LoadDocument(callPDFPreivew());
我没有一个azureblob实例可以对此进行测试,但是流可能需要重新定位。
尝试以快速测试:
using(var memoryStreamFromByte = new MemoryStream(azureFileUpload.PreviewBlob(file.Name)))
{
memoryStreamFromByte.Position = 0;
return memoryStreamFromByte;
}
如果那不起作用,请在此处打开私人支持票,以便我可以直接使用Blob凭据
感谢您的建议,但我能够使用此代码进行工作
using(WebClient client = new WebClient())
{
using(Stream ms = new MemoryStream(client.DownloadData(file.Uri.ToString())))
{
MemoryStream mStream = new MemoryStream();
mStream.SetLength(ms.Length);
ms.Read(mStream.GetBuffer(), 0, (int) ms.Length);
pdfViewer.LoadDocument(mStream);
}
}
这是我从