How to Run the Examples

Aspose.HTML for .NET examples are open-source C# projects hosted in the aspose-html/Aspose.HTML-for-.NET GitHub repository. Use them to test document creation, loading, editing, data extraction, rendering, and conversion workflows before adding similar code to your own application.

For the smoothest setup, open the examples solution in Visual Studio, make sure nuget.org is enabled as a package source, build the project, and keep the repository Data folder together with the examples because many C# samples use those input files.

Software Requirements

Before downloading and running the examples, make sure the development machine meets these requirements:

  1. Install Visual Studio 2010 SP1 or higher. For new projects, Visual Studio 2022 is recommended.
  2. Make sure that NuGet Package Manager is installed in Visual Studio. For details, see the Microsoft documentation for NuGet client tools.
  3. Open Tools > Options > NuGet Package Manager > Package Sources and make sure that nuget.org is enabled.
  4. Keep an active Internet connection for the first build because the example project uses NuGet Automatic Package Restore.
  5. If the machine cannot access NuGet, see Installation and manually add a reference to Aspose.HTML.dll in the example project.
  6. Check System Requirements when running examples on Linux, macOS, Docker, or hosted server environments.

Download Examples from GitHub

All Aspose.HTML for .NET examples are hosted in the Aspose.HTML for .NET GitHub repository.

You can clone the repository with Git:

1git clone https://github.com/aspose-html/Aspose.HTML-for-.NET.git

You can also download the repository as a ZIP archive from GitHub:

1https://github.com/aspose-html/Aspose.HTML-for-.NET/archive/master.zip

To run the C# examples:

  1. Clone the repository or download the ZIP archive.
  2. Extract the ZIP archive to any folder on your computer if you downloaded the archive.
  3. Open the repository and locate the Examples folder.
  4. Keep the Data folder at the root of Examples because the C# examples use its input files.
  5. Open the Visual Studio solution file.
  6. Build the project and let NuGet restore the required dependencies on the first run.
  7. Open RunExamples.cs.
  8. Uncomment the examples you want to run.
  9. Start the project and review the generated output files.

Example Project Notes

The example project was originally created in Visual Studio 2013, and the solution files are compatible with Visual Studio 2010 SP1 and higher. Newer Visual Studio versions can also open and build the examples when the required .NET tooling and NuGet package restore are available.

The Data folder is required. It contains HTML, SVG, images, stylesheets, and other input files used by the C# examples. If the folder is missing, some examples may compile but fail at runtime because the source files cannot be found.

RunExamples.cs is the starting point for running selected examples. Open this file, uncomment the examples you want to execute, and build the project again if needed.

Common Example Setup Issues

IssueCauseFix
NuGet packages are not restorednuget.org is disabled, the machine is offline, or the build environment uses a different NuGet configuration.Enable nuget.org, restore packages again, or manually reference Aspose.HTML.dll as described in Installation.
Examples compile but fail at runtime with missing filesThe Data folder was not downloaded, extracted, or copied together with the Examples project.Download the full repository and keep the Data folder at the root of Examples.
No example appears to runThe target examples are still commented out in RunExamples.cs.Open RunExamples.cs and uncomment the examples you want to execute.
Output differs on another machine or in DockerRendering can depend on fonts, native dependencies, file paths, and network access.Check System Requirements and configure the runtime environment before comparing output.
Visual Studio asks to upgrade the projectThe examples were originally created with an older Visual Studio version.Let a modern Visual Studio version upgrade project metadata if prompted, or use a compatible Visual Studio version for legacy testing.

Contribute

If you want to add or improve an example, you can contribute to the repository. The examples and showcase projects are open source and can be used in your own applications.

To contribute:

  1. Fork the Aspose.HTML for .NET GitHub repository.
  2. Edit or add the example source code.
  3. Keep sample input files in the appropriate data folder when the example needs them.
  4. Create a pull request.
  5. The maintainers will review the change and include it if it is helpful.

If you have issues setting up or running the examples, contact the team through the Aspose.HTML Free Support Forum.

FAQ

Where are the Aspose.HTML for .NET examples stored?

The C# examples are stored in the public aspose-html/Aspose.HTML-for-.NET GitHub repository.

Do I need the Data folder?

Yes. Many examples use input files from the Data folder. Download the full repository and keep the Data folder together with the Examples project.

Can I run only one example?

Yes. Open RunExamples.cs and uncomment only the example or group of examples you want to run.

Can I run the examples without Internet access?

Yes, but you must restore packages or add required DLL references before running them offline. The first build normally needs Internet access for NuGet package restore.

Can I use the example code in my own application?

Yes. The examples are open-source sample projects intended to show how Aspose.HTML for .NET APIs can be used in C# applications.

Next Steps