I am trying to get a pdf document using the stream and I get as "Aspose.Pdf.invalidPdfFileformatException: 'Incorrect file format'"
What I have tried:
<pre>internal async void ExtractImages(CloudFilePath sourcePath, string filePath, CloudFilePath outputFilenameTemplate, int startPage, int endPage, int dpi)
{
var fileStreamContainer = await this.fileSystem.ReadFileAsync(sourcePath, default);
Stream fileStream = new MemoryStream(fileStreamContainer);
string extension = Path.GetExtension(filePath);
var pngDevice = new PngDevice(new Resolution(dpi));
Document doc = new Document(fileStream);
using (var document = new Document(filePath))
{
for (var pageIndex = startPage; pageIndex <= endPage; pageIndex++)
{
using (var stream = File.Create(outputFilenameTemplate.ToString()))
{
pngDevice.Process(document.Pages[pageIndex], stream);
}
}
}
}
I get the error message in the
Document doc = new Document(fileStream);
line of the code. Not sure what I am missing.
I have uploaded the pdf which I also made sure by getting the extension, which also returns as pdf. In the above the filepath is
var filePath = Path.Combine(amazonConfiguration.LocalStack + sourcePath.ToString());
Can anyone help me to fix this issue.