Create a directory for your console app by executing the mkdir my-console-app command in your terminal.
Navigate to the my-console-app directory by executing the cd my-console-app command.
Create an empty console app by executing the dotnet new console command.
Add the GroupDocs.Conversion for .NET package by executing the dotnet add package GroupDocs.Conversion command.
Edit Program.cs and add the following lines to the Main method:
usingGroupDocs.Conversion;usingGroupDocs.Conversion.Options.Convert;stringdocumentPath=@"C:\sample.docx";// NOTE: Put here actual path for your documentstringoutputPath=@"C:\output\converted.pdf";using(Converterconverter=newConverter(documentPath)){PdfConvertOptionsconvertOptions=newPdfConvertOptions();converter.Convert(outputPath,convertOptions);}
Replace the documentPath value with the actual path to the document you’re going to convert.
Run the project by executing the dotnet run command.
The converted document will be saved in the C:\\output\\ directory.
Build a project using Visual Studio
Open Visual Studio and go to File -> New -> Project.
Select the appropriate project type - Console App, ASP.NET Web Application etc.
Install GroupDocs.Conversion for .NET from Nuget or the official GroupDocs website following this guide.
Add the following code to the Main method:
usingGroupDocs.Conversion;usingGroupDocs.Conversion.Options.Convert;stringdocumentPath=@"C:\sample.docx";// NOTE: Put here actual path for your documentstringoutputPath=@"C:\output\converted.pdf";using(Converterconverter=newConverter(documentPath)){PdfConvertOptionsconvertOptions=newPdfConvertOptions();converter.Convert(outputPath,convertOptions);}
Replace the documentPath value with the actual path to the document you’re going to convert.
Build and Run your project.
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.
Navigate to the Examples directory and open the GroupDocs.Conversion.Examples.CSharp.sln solution using Visual Studio.
Open the RunExamples.cs file and uncomment the example(s) that you would like to run.
Optionally, you can set the path to the license in Utils.cs file.
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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.