I have a .docx file stored in Azure Blob Storage. I have written a c# (.NET 6) program, using GdPicture.NET, which is supposed to open the source file as a read stream, create/open a new output blob as a writeable stream, and use the GdPictureDocumentConverter.SaveAsPDF method to convert the source file and write it to the output stream.
Here is my code:
Code: Select all
_log.LogDebug("Unlocking GdPicture.NET with license key");
string gdPictureLicenseKey = _configuration["GdPictureLicenseKey"];
oLicenseManager.RegisterKEY(gdPictureLicenseKey);
_log.LogDebug($"Setting up Document Conversion");
using (GdPictureDocumentConverter oConverter = new())
{
BlobContainerClient containerClient = new(blobContainerUri);
BlockBlobClient blockBlobClientIn = containerClient.GetBlockBlobClient(blobNameIn);
using var inBlobStream = await blockBlobClientIn.OpenReadAsync();
GdPictureStatus status = oConverter.LoadFromStream(inBlobStream);
if (status == GdPictureStatus.OK)
{
_log.LogDebug("File loaded successfully for conversion processing");
BlockBlobClient blockBlobClientOut = containerClient.GetBlockBlobClient(blobNameOut);
using var outBlobStream = await blockBlobClientOut.OpenWriteAsync(true); // Force overwrite
oConverter.PdfImageQuality = 100;
status = oConverter.SaveAsPDF(outBlobStream); // <------ This is where the error status gets generated
oConverter.CloseDocument();
if (status == GdPictureStatus.OK)
{
_log.LogDebug("Converted file saved successfully.");
}
else
{
_log.LogError($"File failed to save. Response: {status}");
}
}
else
{
_log.LogError("The file failed to load for conversion processing.");
}
}
I have verified that the source blob is a valid .docx that I can download and open in Word.
I have verified that the source blob client opens successfully, and CanRead is true.
I have verified that the output blob client opens successfully, and CanWrite is true.
So what am I doing wrong, and how do I fix it, please?
Thanks.
Mark.