Method Convert Func<Stream> obsoleted

Hi, i’m planning upgrade GroupDocs from 24.8 to 24.12, but seems some method is obsoleted in 24.12.

Could you please suggest how to change my existing code to adapt with 24.12?
Thanks.

image.png (59.1 KB)

@akhiong0904
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CONVERSIONNET-7482

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@akhiong0904

Please use following code and let us know if issue persists:

// Initialize result as a byte array to hold the final output
byte[] result = null;

// Create a MemoryStream to store the conversion result
using (var resultStream = new MemoryStream())
{
    // Define a function to get load options for Word processing
    Func<LoadContext, LoadOptions> getLoadOptions = (loadContext) => new WordProcessingLoadOptions
    {
        // Enable text shaping for better text rendering
        UseTextShaper = true
    };

    // Create a converter instance with a new MemoryStream for results and specified load options
    using (var converter = new Converter(() => new MemoryStream(result), getLoadOptions))
    {
        // Initialize PDF conversion options
        var options = new PdfConvertOptions();

        // Check if a password is provided for the PDF and if the output type is PDF
        if (pItem.PDFPassword != null && pItem.PDFPassword != "" && pItem.OutputType.ToLower() == "pdf")
        {
            // Set the password for the PDF options
            options.Password = pItem.PDFPassword;
        }

        // Perform the conversion and save the result to the resultStream
        converter.Convert((SaveContext saveContext) => resultStream, options);
    }

    // Convert the MemoryStream to a byte array to return as result
    result = resultStream.ToArray();
}

Thanks, it works for me

1 Like