How to run examples

We offer multiple solutions on how you can run GroupDocs.Conversion examples, by building your own or using our back-end or front-end examples.

Build a project from scratch

You can build a project from scratch using Visual Studio or .NET CLI. We’ll step you through both cases.

Build a project using .NET CLI

  1. Make sure you have .NET Core or .NET SDK installed https://dotnet.microsoft.com/download.
  2. Create a directory for your console app by executing the mkdir my-console-app command in your terminal.
  3. Navigate to the my-console-app directory by executing the cd my-console-app command.
  4. Create an empty console app by executing the dotnet new console command.
  5. Add the GroupDocs.Conversion for .NET package by executing the dotnet add package GroupDocs.Conversion command.
  6. Edit Program.cs and add the following lines to the Main method:
  using GroupDocs.Conversion;
  using GroupDocs.Conversion.Options.Convert;

  string documentPath = @"C:\sample.docx"; // NOTE: Put here actual path for your document
  string outputPath = @"C:\output\converted.pdf";

  using (Converter converter = new Converter(documentPath))
  {
      PdfConvertOptions convertOptions = new PdfConvertOptions();
      converter.Convert(outputPath, convertOptions);
  }
  1. Replace the documentPath value with the actual path to the document you’re going to convert.
  2. Run the project by executing the dotnet run command.
  3. The converted document will be saved in the C:\\output\\ directory.

Build a project using Visual Studio

  1. Open Visual Studio and go to File -> New -> Project.
  2. Select the appropriate project type - Console App, ASP.NET Web Application etc.
  3. Install GroupDocs.Conversion for .NET from Nuget or the official GroupDocs website following this guide.
  4. Add the following code to the Main method:
  using GroupDocs.Conversion;
  using GroupDocs.Conversion.Options.Convert;

  string documentPath = @"C:\sample.docx"; // NOTE: Put here actual path for your document
  string outputPath = @"C:\output\converted.pdf";

  using (Converter converter = new Converter(documentPath))
  {
      PdfConvertOptions convertOptions = new PdfConvertOptions();
      converter.Convert(outputPath, convertOptions);
  }
  1. Replace the documentPath value with the actual path to the document you’re going to convert.
  2. Build and Run your project.
  3. The converted document will be saved in the C:\\output\\ directory.

Run back-end examples

You can find many back-end examples in our GitHub repository. You can either download the ZIP file from here or clone the repository from GitHub using your favorite Git client.
In case you download the ZIP file, extract the folders on your local disk.

  1. Navigate to the Examples directory and open the GroupDocs.Conversion.Examples.CSharp.sln solution using Visual Studio.
  2. Open the RunExamples.cs file and uncomment the example(s) that you would like to run.
  3. Optionally, you can set the path to the license in Utils.cs file.

Run demo projects

To run any demo from GroupDocs.Conversion for .NET Demo projects, you can either:

  • Clone the repository:

    git clone git@github.com:groupdocs-conversion/GroupDocs.Conversion-for-.NET.git  
    
  • or download the source code.

ASP.NET MVC demo

  1. Clone or download the GroupDocs.Conversion-for-.NET repository from GitHub or skip this step if you already have the code.
  2. Navigate to the Demos/MVC directory.
  3. Open the GroupDocs.Conversion.MVC.sln solution using Visual Studio.
  4. Update common parameters in the **web.config** file and demo-related properties in the **configuration.yml** file to meet your requirements.
  1. Run the project and open http://localhost:8080/conversion in your favorite browser.

ASP.NET Web Forms demo

  1. Clone or download the GroupDocs.Conversion-for-.NET repository from GitHub or skip this step if you already have the code.
  2. Navigate to Demos/WebForms directory.
  3. Open the GroupDocs.Conversion.WebForms.sln solution using Visual Studio.
  4. Update common parameters in the **web.config** file and demo-related properties in the **configuration.yml** file to meet your requirements.
  5. Open http://localhost:8080/conversion in your favorite browser.

Docker demo

Use the Docker image to try GroupDocs.Conversion for .NET features in an easy way. Here are the commands to run GroupDocs.Conversion for .NET from the Docker image.

mkdir DocumentSamples
mkdir Licenses
docker run -p 8080:8080 --env application.hostAddress=localhost  \
    -v `pwd`/DocumentSamples:/home/groupdocs/app/DocumentSamples  \
    -v `pwd`/Licenses:/home/groupdocs/app/Licenses  \
    groupdocs/conversion
## Open http://localhost:8080/conversion in your favorite browser.

Contribute

If you like to add or improve an example, we encourage you to contribute to the project. All examples in this repository are open source and can be freely used in your own applications.
To contribute, you can fork the repository, edit the code and create a pull request. We will review the changes and include them in the repository if found helpful.