In this tutorial you will configure a C# or VB.NET project for a console application and use ImageGear .NET Office capabilities. You will also learn how to open a Word document and save it as a PDF file.
- The following tutorial refers specifically to 64-bit installations.
- For 32-bit installations:
- Your project should already be set to compile to target Debug and x86, and you should have the directory: $YOURLOCALPROJ\bin\x86\Debug\.
- Throughout these instructions, replace x64 with x86.
- The 32-bit ImageGear binaries and 32-bit OfficeCore installer are found in $INSTALLDIR\ImageGear .NET v23\Bin\
Using the desired version of Visual Studio (2010 or later):
- Create a new "Console Application" project using C# or VB.NET and name the project: my_first_Office_project.
- If you installed ImageGear .NET 64-bit using the Configuration Manager, create a new project platform (if you don't have one already) for x64.
Make sure your project is set to compile targeting Debug and x64.
Confirm you now have $YOURLOCALPROJ\bin\x64\Debug\, if not, create it.
- Run the OfficeCore 64-bit installer found in $INSTALLDIR\ImageGear .Net v23 64-bit\Bin\.
- Add references and required resources into your projects in one of the following ways:
- Recommended: use our NuGet Packages. For this project, you need the following packages:
- Manually:
- Copy all files (and folders) inside $INSTALLDIR\ImageGear .NET v23 64-bit\Bin\ to your local output bin directory in your project (i.e., $YOURLOCALPROJ\bin\x64\Debug\ ).
- Add the following references to your project from $YOURLOCALPROJ\bin\x64\Debug\:
- ImageGear23.Core.dll
- ImageGear23.Evaluation.dll
- ImageGear23.Formats.Common.dll
- ImageGear23.Formats.Office.dll
- ImageGear23.Formats.Pdf.dll
- ImageGear23.Formats.Vector.dll
- ImageGear23.Presentation.dll
Your output target directory should be set to $YOURLOCALPROJ\bin\x64\Debug\ .
- Before you can use the Office and PDF functionality, you need to add support for those formats. Add the following code to set up evaluation licensing and add support for common image formats, Office files, and PDF files.
- Now that you have added support for the file types you will be using, you can actually work with them. The following code enables you to load a Word document into an ImGearDocument, which will hold the entire loaded document. You can save that ImGearDocument as a PDF.
- Once you are done with the PDF component, you should dispose it.
- Finally, by putting all the above code snippets together your console application should look like the code below: