Free Support Forum - aspose.com

How to use Licensing aspose in my project?

In my project, I have the Aspose.Words.dll reference, and in the same Bin folder I have my Aspose.Words.lic file, when I am generating my files a message is appearing as if I had not purchased the component. How can I link the license to the project?

    public void NovaImpressaoCartas()
    {
        //OBS - vários documentos separados por arquivo
        // O caminho para o diretório de documentos.
        string dataDir = AppDomain.CurrentDomain.BaseDirectory;

        //faz a consulta no banco
        DataTable data = new DataTable();
        string id = "0";
        ConsultaImpressao(data, id, "0");
        data.TableName = "DADOS";

        try
        {
            if (data.Rows.Count > 0)
            {
                //abre o documento modelo
                string caminhoModelo = CaminhoPastaRelatorioNotificacao + data.Rows[8]["modelo"].ToString();

                //criar nome do diretório para cartas
                string caminhoSaida = dataDir + CaminhoPastaTempCarta +  data.Rows[2]["DT_NOTIFICACAO"].ToString().Replace(":", "-").Replace(" ", "-").Replace("/", "-").Trim();

                //criar o diretório
                if (!Directory.Exists(caminhoSaida))
                {
                    Directory.CreateDirectory(caminhoSaida);
                }

                Document doc = new Document(dataDir + caminhoModelo);

                int counter = 1;
                // Faz loop em todos os registros na fonte de dados.
                foreach (DataRow row in data.Rows)
                {
                    // Clone o modelo em vez de carregá-lo do disco(para ser mais rápido ).
                    Document dstDoc = (Document)doc.Clone(true);

                    // Execute mala direta.
                    dstDoc.MailMerge.Execute(row);

                    // Salve o documento, estou usando o nome do contribuinte
                    string NomeArquivoFinal = row["CONTRIBUINTE"].ToString();
                    dstDoc.Save(string.Format(caminhoSaida + "\\" + NomeArquivoFinal+"{0}.pdf", counter++), SaveFormat.Pdf);

                }

                //zipa o arquivo
                CompactarDiretorio(caminhoSaida, caminhoSaida);

            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

    }

This Topic is created by sohail.aspose using the Email to Topic plugin.

@itasouza,

You need to execute the following two lines before creating a Document object:

Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense("Aspose.Words.lic"); 

Please refer to the following article for more details:

Licensing Aspose.Words for .NET

Hello awias.hafeez
Very good, congratulations, fantastic component, in my project now everything is working perfectly, good investment aspose.

It looks like this:

Aspose.Words.License license = new Aspose.Words.License();
license.SetLicense(“Aspose.Words.lic”);
Document doc = new Document(dataDir + caminhoModelo);

@itasouza,

It is great you were able to find what you were looking for. Please let us know any time you have any further queries.