PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Mar 04, 2024 9:59 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Sep 14, 2023 4:48 pm 
Offline

Joined: Thu Sep 14, 2023 4:31 pm
Posts: 2
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;


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 14, 2023 8:32 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 901
Location: CCAA
See also:
http://forum.pdfsharp.net/viewtopic.php?f=2&t=832

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group