我正在尝试使用 Telerik 的 RadPdfViewer,但遇到了问题。我似乎无法让它加载任何文档。我正在尝试从 blob 的 azure 存储中通过流加载,我已正确连接到该文件,但我似乎无法让 pdf 查看器显示 pdf。
如果有人能指出我正确的方向,将不胜感激
这是我从 blob 中获取 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());