Digital sign memory stream(excel, csv) and convert them into PDF

  1. Does ASPOSE library support Excel/csv memory stream as an input parameter and sign them and convert into PDF?
  2. Dose ASPOSE library support C# and Java?

@nchada,
Aspose.Cells for .NET API supports .NET while Aspose.Cells for Java can be used in Java environment. For signing excel files, see the documents with example code for your reference:

its a web application and we have a Excel,csv and pdf memory stream.
would Aspose support to digital sign the memorystream and convert them into pdf and password protect ?

@nchada,
Aspose.Cells provides features to digitally sign and password protect the memory stream and save it as PDF. Please give a try to the following sample code and share the feedback.

//Certificate file and its password
string certFileName = @"C:\test\testcert1.pfx";
string password = "testcert1";

//Create a template workbbok for teting
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();

MemoryStream str = workbook.SaveToStream();

//Load the stream into workbook
Workbook wb2 = new Workbook(str);

//Create the digital signature collection
Aspose.Cells.DigitalSignatures.DigitalSignatureCollection dsCollection = new Aspose.Cells.DigitalSignatures.DigitalSignatureCollection();

//Create new certificate
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certFileName, password);

//Create new digital signature and add it in digital signature collection
Aspose.Cells.DigitalSignatures.DigitalSignature signature = new Aspose.Cells.DigitalSignatures.DigitalSignature(certificate, "Aspose.Cells added new digital signature.", DateTime.Now);
dsCollection.Add(signature);

//Add digital signature collection inside the workbook
wb2.AddDigitalSignature(dsCollection);


// Specify XOR encryption type.
wb2.SetEncryptionOptions(EncryptionType.XOR, 40);

// Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
wb2.SetEncryptionOptions(EncryptionType.StrongCryptographicProvider, 128);

// Password protect the file.
wb2.Settings.Password = "1234";

//Save the workbook and dispose it.
//workbook.Save("outputDigitallySignedByCells.xlsx");
MemoryStream pdfStream = new MemoryStream();
wb2.Save(pdfStream, Aspose.Cells.SaveFormat.Pdf);
//OR
wb2.Save(@"c:\test\output.pdf", Aspose.Cells.SaveFormat.Pdf);

wb2.Dispose();

we are creating a memory stream from DB data and I tried with your sample and it is throwing an error : This file’s format is not supported or you don’t specify a correct format.

here I am giving a sample memory stream format. can you please try on your end ?

public MemoryStream GetFullDemographicsDetails()
{
MemoryStream demographicsStream = new MemoryStream();
byte[] demographicsArray = null;

        //Get the List seperator from the Regional settings of the system.
        string listSeperator = Thread.CurrentThread.CurrentCulture.TextInfo.ListSeparator;

        // Add Report header info to the StringBuilder
        string reportHeader = ("DemographicsReport" + listSeperator + listSeperator + "Respironics" + listSeperator + listSeperator +
                  "Printedby" + listSeperator + "softwareVersion" + listSeperator + listSeperator + "PrintedDate" + listSeperator + listSeperator +
                  DateTime.Today.ToShortDateString() + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator +
                  listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator +
                  listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator +
                  listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator + listSeperator +
                  listSeperator + "\n");

        // Add column names to the StringBuilder
        string columnNames = ("LastName" + listSeperator +
                   "FirstName" + listSeperator +
                   "MiddleName" + listSeperator +
                   "PatientID" + listSeperator + "\n");

        demographicsArray = Encoding.UTF8.GetBytes(reportHeader);
        demographicsStream.Write(demographicsArray, 0, demographicsArray.Length);

        demographicsArray = Encoding.UTF8.GetBytes(columnNames);
        demographicsStream.Write(demographicsArray, 0, demographicsArray.Length);

       
        string detailItem = string.Empty;

            detailItem = String.Format("\"{0}\"{4}\"{1}\"{4}\"{2}\"{4}\"{3}\"{4}",
                 "LastName",
                "FirstName",
                 "MiddleName",
                 "PatientID", listSeperator);           

            detailItem += "\"\n";

            demographicsArray = Encoding.UTF8.GetBytes(detailItem);
            demographicsStream.Write(demographicsArray, 0, demographicsArray.Length);            

        return demographicsStream;
    }

@nchada,
It looks same issue, “file’s format is not supported”, as you reported in other topic. We are checking it and provide our feedback soon.

@nchada,
Please have a look here for your issue.