Error while downloading pdf template from azure blob storage
I am getting an error while downloading a pdf template from azure blob storage, i intend to use this template to fill data and process further in my code without saving in local, and finally upload it back to azure blob.
Error reads as : "Unexpected token 'endobj' in PDF stream. The file may be corrupted. If you think this is a bug in PDFSharp, please send us your PDF file."
below is my code:
BlobClient blobClient = _ClientGet.GetBlobClient(pathAndFileName);
if (await blobClient.ExistsAsync()) { BlobDownloadInfo download = await blobClient.DownloadAsync();
if (download.ContentLength > 0) { byte[] pdfBytes = new byte[download.ContentLength]; await download.Content.ReadAsync(pdfBytes, 0, (int)download.ContentLength);
using (MemoryStream pdfStream = new MemoryStream(pdfBytes)) { PdfDocument pdfDocument = PdfReader.Open(pdfStream, PdfDocumentOpenMode.Import); return pdfDocument; } } }
return null;
|