ImageGear .NET - Updated
Getting Started with ImageGear Office
User Guide > How to Work with... > Formats with Additional Functionality > Office > Getting Started with ImageGear Office
Before using the ASP.NET samples, a path to the Office components must be added to the registry. See Samples for details.

Office Samples and Tutorials

Our suite of Office samples will help you get started using ImageGear’s Office capabilities.

This section also provides a step-by-step Office tutorial, which shows you how to create a new ImageGear project using the Office component:

ImageGear.Formats.Office Namespace

The ImageGear.Formats.Office namespace provides support for PowerPoint, Excel, and Word formats. This allows you to load and display Microsoft Word, Excel, and PowerPoint documents. It also allows you to extract text from Word and PowerPoint documents.

To enable the ImageGear.Formats.Office Namespace in your project, specify the following directive:

C# Example
Copy Code
using ImageGear.Formats.Office;

Converting Office Files to PDF

It is easy to convert all types of Office documents that we support to PDF. See code examples in Microsoft Office Documents to PDF.

Office Dependencies

NuGet Packages

NuGet packages make it easy to add, remove, and update libraries and tools in Visual Studio projects that use the .NET Framework. See NuGet Packages for more information.

Deployment Packaging Wizard

  1. To ensure that you have all the required library files, please run the Deployment Packaging Wizard located at …\Accusoft\ImageGear.NET v23\Licensing\Deployment \DPW.exe or navigate to Start menu >All Programs > Accusoft > ImageGear .NET v23 > Deployment Kit > Deployment Packaging Wizard. For more information, see Deployment Packaging Wizard, if needed.
  2. Please ensure that your Visual Studio build environment is set properly. This can be checked or changed by the following:
    1. From the project properties:
      • On the Build tab, check/change the Platform target property to the appropriate x86/x64. At the top, also make sure the Platform property is set to the same.
      • On the Build tab, in the Output section, make sure Output path property is pointing to the same location as your dlls, i.e., bin\RunTime\NET\
      • On the Debug tab, check/change the Platform property to the correct platform.
    2. Select Build from the pull down menus, and click Configuration Manager…
      • Check/change the Active solution platform property to the correct x86/x64 platform.
      • Click Close.

Working with Office Files

When loading extremely complex or large documents, the user interface can occasionally freeze. In order to avoid this, since all calls are thread safe, you can simply load the document in another thread.

When working with ImGearDocumentImGearExcelBookDocumentImGearExcelSheetDocumentImGearPowerPointDocument, or ImGearWordDocument objects, it is necessary to dispose of them after they are no longer being used.

The best way is simply to use a using statement, like this:

C# Example
Copy Code
using (FileStream inStream = new FileStream(fileIn, FileMode.Open, FileAccess.Read))
using (ImGearWordDocument wordDoc = (ImGearWordDocument)ImGearFileFormats.LoadDocument(inStream))
{

  // Your code here.

}
VB.NET Example
Copy Code
Using inStream As New FileStream(fileIn, FileMode.Open, FileAccess.Read)
Using wordDoc As ImGearWordDocument = DirectCast(ImGearFileFormats.LoadDocument(inStream), ImGearWordDocument)

  ' Your code here.

End Using
End Using

Otherwise, you can simply call the object’s Dispose method.

C# Example
Copy Code
using (FileStream inStream = new FileStream(fileIn, FileMode.Open, FileAccess.Read))
{

  // Load Office document.
  ImGearWordDocument wordDoc = (ImGearWordDocument)ImGearFileFormats.LoadDocument(inStream);

  // Your code here.

  // Dispose of the document when we are done with it.
  wordDoc.Dispose();

}
VB.NET Example
Copy Code
Using inStream As New FileStream(fileIn, FileMode.Open, FileAccess.Read)
  Dim wordDoc As ImGearWordDocument = DirectCast(ImGearFileFormats.LoadDocument(inStream), ImGearWordDocument)

  ' Your code here.

  wordDoc.Dispose()
End Using

The LibreOffice Instance Manager

If you want to adjust the number of LibreOffice processes ImageGear uses to work with Office documents, you can tweak the settings exposed by the LibreOffice Instance Manager. See LibreOffice Instance Manager (LIM) for more information.