Hardcoding loadoption

Hi i got a problem where some of my files are not recognized by aspose’s Save() method, in short it cant recognize them because they are not valid html files etc. So i want to hardcode the document type so the SaveMethod doesent need to. The code i use today is with static Enum:

public string ConvertDocumentFormat(byte[] document, string fromFormat,string ToFormat)
{
    using (MemoryStream docStream = new MemoryStream(document))
    {
       
            LoadOptions lo = new LoadOptions();
            lo.LoadFormat = LoadFormat.Html;
            Document doc = new Document(docStream, lo);
        
        // Save the document as PDF into a stream.
        using (MemoryStream pdfStream = new MemoryStream())
        {                   
            doc.Save(pdfStream, SaveFormat.Pdf);
            // Get base64 string from the resulting stream.
            string pdfBase64String = Convert.ToBase64String(pdfStream.ToArray());
            return pdfBase64String;

        }
    }
}

Here i have hardcoded that all documents to the method are of html type. I want to make this more dynamic and use a parameter. How can i do that ?

@henrikJohansen93 For the loading of a document you could use the Document class constructor without LoadOptions parameter. In this case Aspose.Words will detect the file format by itself. For the saving of the document you should provide the save format either via SaveFormat or SaveOptions parameters. The code could be like this:

public string ConvertDocumentFormat(byte[] document, SaveFormat ToFormat)
{
    using (MemoryStream docStream = new MemoryStream(document))
    {
        Document doc = new Document(docStream);

        // Save the document as PDF into a stream.
        using (MemoryStream outputStream = new MemoryStream())
        {
            doc.Save(outputStream, ToFormat);

            // Get base64 string from the resulting stream.
            string outputBase64String = Convert.ToBase64String(outputStream.ToArray());
            return outputBase64String;
        }
    }
}