Converting word byte array to pdf byte array in Aspose pdf document

We have upgraded Aspose .PDF version: 23.5.0 after that below code was not working and throwing the error: Startxref not found.
Please review my code and provide the update.

private static byte[] ConvertWordToPdf(byte[] buffer, PdfSecurity pdfSecurity)
{

    Settings settings = new Settings();
    //Set the license
    Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
    pdfLicense.SetLicense(new MemoryStream(Properties.Resources.Aspose_Total));

    Aspose.Words.License wordLicense = new Aspose.Words.License();
    wordLicense.SetLicense(new MemoryStream(Properties.Resources.Aspose_Total));

    Aspose.Pdf.Document doc;

    //Pdf pdf = new Pdf();
    Aspose.Pdf.Document pdf = new Aspose.Pdf.Document();

    //Aspose.Pdf.Security asposePdfSecurity = new Aspose.Pdf.Security();
    PdfFileSecurity asposePdfSecurity = new PdfFileSecurity();
    Permissions permission = Permissions.PrintingQuality;

    if (pdfSecurity != null)
    {
        if (pdfSecurity.DocumentAssemblyAllowed)
        {
            permission = Permissions.AssembleDocument;
        }

        if (pdfSecurity.ContentsModifyingAllowed && pdfSecurity.PrintingAllowed && pdfSecurity.FillingFormFieldsAllowed)
        {
            permission = Permissions.ModifyContent & Permissions.PrintDocument & Permissions.FillForm;
        }
        else if (pdfSecurity.ContentsModifyingAllowed && pdfSecurity.PrintingAllowed)
        {
            permission = Permissions.ModifyContent & Permissions.PrintDocument;
        }
        else if (pdfSecurity.PrintingAllowed && pdfSecurity.FillingFormFieldsAllowed)
        {
            permission = Permissions.PrintDocument & Permissions.FillForm;
        }
        else if (pdfSecurity.ContentsModifyingAllowed && pdfSecurity.FillingFormFieldsAllowed)
        {
            permission = Permissions.ModifyContent & Permissions.FillForm;
        }


        if (pdfSecurity.UserPassword != null && pdfSecurity.MasterPassword != null && pdfSecurity.Encryption128Bit)
        {
            pdf.Encrypt(pdfSecurity.UserPassword, pdfSecurity.MasterPassword, permission, CryptoAlgorithm.AESx128);
        }

    }

    using (MemoryStream bufferStream = new MemoryStream(buffer))
    {
        doc = new Aspose.Pdf.Document(bufferStream);
    }
    using (MemoryStream pdfXmlStream = new MemoryStream())
    {
        doc.Save(pdfXmlStream, Aspose.Pdf.SaveFormat.Pdf);
        //pdf.BindXML(pdfXmlStream, null);
        pdf.BindXml(pdfXmlStream, null);
    }
    MemoryStream returnStream = new MemoryStream();
    if (new Settings().IsPdfWatermarked)
    {
        FormatConverter.AddWatermarkToPdf(pdf);
    }
    pdf.Save(returnStream);
    return returnStream.ToArray();
}

@Lakshmibabukandula

You are facing this error because you are trying initialize Aspose.Pdf.Document with the bytes of a Word document. Please note that Aspose.PDF does not provide feature to convert a DOC/DOCX to PDF. This is served by Aspose.Words. Please use Aspose.Words in order to carry the conversion operation and let us know if you still face any issues.