Converting to PDF in Azure

Hi,

Currently I’m using VisualStudio 2017 (15.9.8) and Aspose.Words 17.10.0.0 for Azure development.
I’m trying to convert word document stored in Azure storage to PDF and save the newly created PDF back to azure storage. The problem is that Aspose.Words returned this exception while loading the document stream:

The remote server returned an error: (416) Requested range not satisfiable: response with content range denied.

The code:

CloudBlob cloudBlob = blobContainer.GetBlobReference(blobItem.Name);
using (var stream = cloudBlob.OpenRead())
{
   stream.Position = 0;
   using (Stream pdfStream = new System.IO.MemoryStream())
   {
       UnlockAspose();
       Aspose.Words.Document document = new Aspose.Words.Document(stream); // error here
       document.Save(pdfStream, Aspose.Words.SaveFormat.Pdf);
       pdfStream.Position = 0;

    //CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blobItem.Name + ".pdf");
    //blob.UploadFromStream(pdfStream);
   }
}

The same behaviour also accured in other Aspose.Totals family (Cells, Diagram and Slides).
Any idea to fix this issue?

Thank you in advance.

Cheers,
Inoel

@inoel,

Thanks for the details.

It looks like the issue is not related to Aspose APIs. Well, retrieving streams from and storing them back into BLOB repository is out of our scope and out of Aspose APIs’ responsibility. You should check and figure it out by yourself. This is the only instruction fit into Aspose API (e.g Aspose.Words) scope:

Aspose.Words.Document document = new Aspose.Words.Document(stream);

It might possible that source document contained in stream is broken or corrupt, so you should evaluate if the stream is containing the actual file fine or not. Even you may exclude Aspose API and use .NET APIs only to test the scenario/ case if you can open/read the file stream.

Hi Amjad,

There’s probably some bits missing or something indeed.
I just got it working after restarting my computer.

Cheers,
Inoel

@inoel,

Good to know that your issue is sorted out. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.