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();
}