Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Sometimes, in order to study the system better, you want to dive into the code as fast as possible. To make this easier, Aspose.Words provides different plans for purchase or offers a Free Trial and a 30-day Temporary License for evaluation.
Aspose.Words is incredible software that developers can try before purchasing.
The evaluation version is the same as the purchased one – the Trial version simply becomes licensed when you add a few lines of code to apply the license.
The Trial version of Aspose.Words without the specified license provides full product functionality, but inserts an evaluative watermark at the top of the document upon loading and saving and limits the maximum document size to a few hundred paragraphs.
If you wish to test Aspose.Words without the limitations of the Trial version, you can also request a 30-day Temporary License. For more details, see the Get a Temporary License page.
After purchase, you need to apply the license file or include the license file as an embedded resource. This section describes options of how this can be done, and also comments on some common questions.
You need to set the license:
After purchasing a license, you need to carefully read the information on page Protecting Your Purchased License to protect your license file. Please note that this page is available for viewing only if you have a paid license.
Licenses can be applied from various locations:
Aspose.Words_\*.dll
fileAspose.Words_\*.dll
.exe
)Aspose.Words_\*.dll
Often the easiest way to set a license is to place the license file in the same folder as Aspose.Words_\*.dll
and specify just the filename without the path.
Use the SetLicense method to license a component.
Calling SetLicense multiple times is not harmful, it just wastes processor time.
When developing your application, call SetLicense in your startup code before using Aspose.Words classes.
Using the SetLicense method, you can try to find the license file in the embedded resources or assembly folders for further use.
The following code example shows how to initialize a license from a folder:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C.git. | |
auto license = MakeObject<License>(); | |
// This line attempts to set a license from several locations relative to the executable and Aspose.Words.dll. | |
// You can also use the additional overload to load a license from a stream, this is useful, | |
// for instance, when the license is stored as an embedded resource. | |
try | |
{ | |
license->SetLicense(u"Aspose.Words.Cpp.lic"); | |
std::cout << "License set successfully." << std::endl; | |
} | |
catch (System::Exception& e) | |
{ | |
// We do not ship any license with this example, | |
// visit the Aspose site to obtain either a temporary or permanent license. | |
std::cout << (String(u"\nThere was an error setting the license: ") + e->get_Message()) << std::endl; | |
} |
The following code example shows how to initialize a license from a stream using another SetLicense method:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C.git. | |
auto license = MakeObject<License>(); | |
try | |
{ | |
license->SetLicense(MakeObject<System::IO::MemoryStream>(System::IO::File::ReadAllBytes(u"Aspose.Words.Cpp.lic"))); | |
std::cout << "License set successfully." << std::endl; | |
} | |
catch (System::Exception& e) | |
{ | |
// We do not ship any license with this example, | |
// visit the Aspose site to obtain either a temporary or permanent license. | |
std::cout << (String(u"\nThere was an error setting the license: ") + e->get_Message()) << std::endl; | |
} |
A neat way to package a license with your application and make sure it will not be lost is to include it as an embedded resource. The way how to embed and use resources depends on your target platform.
Let’s suppose you have added the license as a resource as shown below.
resource.h
#define IDR_ASPOSE_WORDS_LIC 101
resource.rc
IDR_ASPOSE_WORDS_LIC RCDATA "Aspose.Words.Cpp.lic"
The following code example shows how to initialize a license from an embedded resource using SetLicense method:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C.git. | |
auto hResource = FindResource(nullptr, MAKEINTRESOURCEA(IDR_ASPOSE_WORDS_LIC), RT_RCDATA); | |
auto hMemory = LoadResource(nullptr, hResource); | |
auto size = SizeofResource(nullptr, hResource); | |
auto ptr = LockResource(hMemory); | |
auto licResource = System::MakeArray<uint8_t>(size); | |
std::copy_n(static_cast<const uint8_t*>(ptr), size, licResource->begin()); | |
FreeResource(hMemory); | |
auto license = System::MakeObject<License>(); | |
try | |
{ | |
license->SetLicense(MakeObject<System::IO::MemoryStream>(licResource)); | |
std::cout << "License set successfully." << std::endl; | |
} | |
catch (System::Exception& e) | |
{ | |
std::cout << (String(u"\nThere was an error setting the license: ") + e->get_Message()) << std::endl; | |
} |
There is a similar way to embed resources on Linux in an executable.
The following code code example shows how to initialize a license from an embedded resource using SetLicense method:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C.git. | |
// A file named Aspose.Words.lic is 'imported' into an object file | |
// using the following command: | |
// | |
// ld -r -b binary -o aspose.words.lic.o Aspose.Words.lic | |
// | |
// That creates an object file named "aspose.words.lic.o" with the following | |
// symbols: | |
// | |
// _binary_aspose_words_lic_start | |
// _binary_aspose_words_lic_end | |
// _binary_aspose_words_lic_size | |
// | |
// Note that the symbols are addresses | |
extern uint8_t _binary_aspose_words_lic_start[]; | |
extern uint8_t _binary_aspose_words_lic_end[]; | |
extern uint8_t _binary_aspose_words_lic_size[]; | |
std::ptrdiff_t size = _binary_aspose_words_lic_end - _binary_aspose_words_lic_start; | |
auto licResource = System::MakeArray<uint8_t>(size); | |
std::copy(_binary_aspose_words_lic_start, _binary_aspose_words_lic_end, licResource->begin()); | |
auto license = MakeObject<License>(); | |
try | |
{ | |
license->SetLicense(MakeObject<System::IO::MemoryStream>(licResource)); | |
std::cout << "License set successfully." << std::endl; | |
} | |
catch (System::Exception& e) | |
{ | |
std::cout << (String(u"\nThere was an error setting the license: ") + e->get_Message()) << std::endl; | |
} |
The license filename does not have to be “Aspose.Words.LIC”. You can rename it to your liking and use that name when setting a license in your application.
When you purchase and download a license, the Aspose website names the license file “Aspose.Words.LIC”. You download the license file using your browser. In this case, some browsers recognize the license file as XML and append the .xml extension to it, so the full file name on your computer becomes “Aspose.Words.lic.XML”.
When Microsoft Windows is configured to hide extensions for known file types (unfortunately, this is the default in most Windows installations), the license file will appear as “Aspose.Words. LIC” in Windows Explorer. You will probably think that this is the real file name and call SetLicense passing it “Aspose.Words.LIC”, but there is no such file, hence the exception.
To solve the problem, rename the file to remove the invisible .xml extension. We also recommend you disable the “hide extensions” option in Microsoft Windows.
If you use multiple Aspose products in your application, such as Aspose.Words and Aspose.Cells
, here are a few useful tips:
Aspose.Cells
has Aspose.Cells
.License class. Using the fully qualified class name allows you to avoid confusion as to which license applies to which product.Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.