Hi,
I am having trouble with a purchased license for ASPOSE.Total for .NET.
Here is the code used, the license still shows as ‘Evaluation’ but I am applying the license file.
The code is writing the PDF to Excel and outputting to filesystem (and also SharePoint after). The filesystem excel is attached
See output file attached and sample code below. Please confirm this license is correct if there is something incorrect with code or implementation, thanks
(I open the xlsx file in notepad and it says it is evaluation copy, is this correct? I think it should be full version.)
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
EventFiringEnabled = false;
var license = new Aspose.Cells.License();
license.SetLicense("Aspose.Total.lic");
SPWeb web = properties.Web;
Aspose.Pdf.Document doc =
new Aspose.Pdf.Document(properties.ListItem.File.OpenBinaryStream());
SPFile file = null;
using (var memoryStream = new MemoryStream())
{
using (var stream = properties.ListItem.File.OpenBinaryStream())
stream.CopyTo(memoryStream);
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
Aspose.Pdf.Text.TextAbsorber absorber = new Aspose.Pdf.Text.TextAbsorber();
absorber.TextSearchOptions.LimitToPageBounds = true;
pdfDoc.Pages.Accept(absorber);
File.WriteAllText(@"E:\Shared\temp_modified123.txt", absorber.Text);
pdfDoc.Save(memoryStream, Aspose.Pdf.SaveFormat.Excel);
Aspose.Cells.Workbook workBook = new Workbook(memoryStream);
workBook.Save(@"E:\Shared\temp_modified123.xlsx");
// Convert the document to byte form.
byte[] docBytes = memoryStream.ToArray();
using (MemoryStream inStream = new MemoryStream(docBytes))
{
//Save from memory stream to SharePoint
file = properties.List.RootFolder.Files.Add(
SPUrlUtility.CombineUrl(web.ServerRelativeUrl, properties.List.RootFolder.Url + "/"
+ properties.ListItem.File.Name
.ToLower().Trim().Replace(".pdf", ".xlsx")),
inStream);
file.Update();
}
}
}
catch (Exception er)
{ }
finally
{
base.ItemAdded(properties);
EventFiringEnabled = true;
}
}