Trouble converting documents to PDF using Azure Blob Storage

Discussions about PDF management.
Post Reply
jewelerm
Posts: 1
Joined: Tue May 17, 2022 8:56 pm

Trouble converting documents to PDF using Azure Blob Storage

Post by jewelerm » Tue May 17, 2022 9:16 pm

I am evaluating GdPicture.Net, and having difficulty trying to complete my first test...

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.");
                    }
                }
When the SaveAsPDF line gets executed, status gets set to UnsupportedFormat.

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.

Hugo
Posts: 174
Joined: Tue Dec 18, 2018 10:09 am

Re: Trouble converting documents to PDF using Azure Blob Storage

Post by Hugo » Wed May 18, 2022 3:47 pm

Hi there,

Thanks for providing this.

I have responded to you in the ticket you created to contact us.
As this could be due to any number of things I am waiting for your response there so we may get to the bottom of this.

Regards,
Hugo Cudd
Technical Support

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest