You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to download a PDF from an Azure blob storage and then trying to call the PdfDocument.Open(ms) function. The PDF is a very simple one containing following two words in it - Toy car
var containerexists = await containerClient.ExistsAsync();
if (!containerexists)
{
throw new Exception($"Blob Container {attachmentContainerName} does not exist!");
}
var blobclient = containerClient.GetBlobClient($"{AttachmentContainerFolder.temp}/{tenantId}/{profileId}/{fileName}");
string text = null;
if (blobclient.Exists())
{
var downloadContent = await blobclient.DownloadStreamingAsync();
using (MemoryStream ms = new MemoryStream())
{
await downloadContent.Value.Content.CopyToAsync(ms);
try
{
using (var document = PdfDocument.Open(ms))
{
}
}
catch(Exception e)
{
}
}
}
return null;
}
`
I get below exception on this LOC - using (var document = PdfDocument.Open(ms))
Exception details:
Exception message - Could not read the first token in the document at position 28937.
Stack Trace –
at UglyToad.PdfPig.Parser.FileStructure.FileHeaderParser.Parse(ISeekableTokenScanner scanner, Boolean isLenientParsing, ILog log)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, ILog log, Boolean isLenientParsing, IReadOnlyList`1 passwords, Boolean clipPaths)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytes inputBytes, ParsingOptions options)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Stream stream, ParsingOptions options)
at UglyToad.PdfPig.PdfDocument.Open(Stream stream, ParsingOptions options)
at Eris.DocumentWorkFlow.Services.DocumentService.d__10.MoveNext() in C:\Users……
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am trying to download a PDF from an Azure blob storage and then trying to call the PdfDocument.Open(ms) function. The PDF is a very simple one containing following two words in it - Toy car
Below is my code:
`public async Task DownloadAttachment(string tenantId, string profileId, string fileName)
{
BlobServiceClient blobServiceClient = new BlobServiceClient(_config["ProfileStorage"]);
var attachmentContainerName = _config["ContainerName"];
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(attachmentContainerName);
`
I get below exception on this LOC - using (var document = PdfDocument.Open(ms))
Exception details:
Exception message - Could not read the first token in the document at position 28937.
Stack Trace –
at UglyToad.PdfPig.Parser.FileStructure.FileHeaderParser.Parse(ISeekableTokenScanner scanner, Boolean isLenientParsing, ILog log)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.OpenDocument(IInputBytes inputBytes, ISeekableTokenScanner scanner, ILog log, Boolean isLenientParsing, IReadOnlyList`1 passwords, Boolean clipPaths)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(IInputBytes inputBytes, ParsingOptions options)
at UglyToad.PdfPig.Parser.PdfDocumentFactory.Open(Stream stream, ParsingOptions options)
at UglyToad.PdfPig.PdfDocument.Open(Stream stream, ParsingOptions options)
at Eris.DocumentWorkFlow.Services.DocumentService.d__10.MoveNext() in C:\Users……
Beta Was this translation helpful? Give feedback.
All reactions