Create a Web API Application with our Office File API (Powered by the platform-agnostic DevExpress.Drawing Graphics Engine)
Tags: devexpress, webapi, documentprocessing, officefileapi
Published: 2023-11-13 11:20:34

In our summer v23.1 major release, our new DevExpress Drawing graphics library was released to manufacturing (RTM). 
This new engine is available for the following DevExpress products:

1. [Office File API](https://www.devexpress.com/products/net/office-file-api/)
2. [Reporting](https://www.devexpress.com/subscriptions/reporting/)
3. [BI Dashboard](https://www.devexpress.com/products/net/dashboard/)

I am starting a new blog post series where I’ll describe how to use our cross-platform engine and maximize its full potential. In this particular blog post, I'll show you how to integrate [Office File API](https://www.devexpress.com/products/net/office-file-api/) functionality in Web API applications. But first, let me give a brief explanation of what the DevExpress.Drawing library is.

## DevExpress.Drawing Library: Backstory

Microsoft attributed `System.Drawing.Common` as a Windows-specific library in .NET 6 and higher: [System.Drawing.Common only supported on Windows](https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only). This breaking change affected the DevExpress cross-platform products - components that use `System.Drawing.Common` as a rendering/text measurement engine - including Reporting, Office File API and BI Dashboards.

To address issues with the `System.Drawing.Common` package, we introduced a new [DevExpress.Drawing](https://docs.devexpress.com/CoreLibraries/404247/devexpress-drawing-library) assembly in our v22.1 release cycle. This assembly contains custom implementations of all `System.Drawing` classes not supported for non-Windows systems. We made a series of enhancements during the 22.1 and 23.1 release cycles, and the library reached its final state in v23.1.

DevExpress.Drawing is `gdiplus`-independent and works on DevExpress primitives. This means that you can use supported components within applications that target different operating systems (Linux, macOS) and cloud services (Azure, AWS). Our internal test results demonstrate that the new engine works with the same efficiency as our previous GDI+ engine.

Our new approach allows our cross-platform products to work as expected across all supported platforms/target frameworks. And this change has opened up numerous opportunities in other areas.

## Organize and Convert Files in a Web API Application

Web API (Application Programming Interface) offers numerous benefits. Web API is platform-agnostic, which means it can be used across various devices and operating systems.

Our Office File API suite allows you to organize Word, Excel, and PDF documents. Each library in the suite ships with a comprehensive set of features, such as PDF/HTML conversion, mail merge, digital signature support, etc.

You can integrate our DevExpress Office File API into a Web API app and then consume available endpoints from frontend apps built using any programming language. This increases reach and allows you to introduce Excel, Word, and PDF-related document management functionality across platforms.

To help illustrate what's possible, I created an Office File API in Web API apps sample solution. Please refer to the following link for more information: [Office File API - Use DevExpress Office File API Libraries (at the backend) for your Web-API Applications](https://github.com/DevExpress-Examples/office-file-api-in-web-api-app)

**Important Note:** You need to purchase a license to use the DevExpress Office File API in production code (either the [DevExpress Office File API Subscription](https://www.devexpress.com/products/net/office-file-api/) or [DevExpress Universal Subscription](https://www.devexpress.com/subscriptions/universal.xml))

My example uses Swagger UI, but you can change the client-side implementation to suit your specific requirements.


![web api main view](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t8khxwaa84d0c0o52scw.png)

The project contains a set of endpoints for the popular tasks you can address when using the DevExpress Office File API. These pre-built functions and services accelerate the development process so you can focus on the unique aspects of your application rather than building everything from scratch.

Let’s take a look at document conversion and organization (merge and split documents) as an example.

### Convert Documents

We prepared conversion endpoints to Word and Excel files. The web request allows you to load a file (file format is detected automatically). The drop-down menu displays available conversion formats.

![web api conversion](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9jvidygbwmog1pic88r.png)

You can download the result (after successful conversion) in the **Response** section.


![web api result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pojavpnd0ll4kodrqp4a.png)

### Merge and Split Files

The merge and split endpoints are available for Word, Excel, and PDF files. Load files to merge and select the format of the resulting file. Download the result in the **Response** section.


![web api merge](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7g9bhwpx2pqxa9kijoxh.png)

As for splitting, the web request splits the loaded file page-by-page and exports results to a zip file with documents in the selected format.

The endpoints described herein illustrate the basic implementation of conversion, split, and merge operations. You can download and modify the project based on specific requirements. Refer to the following articles for additional information in this regard:

- [Word Processing Document API](https://docs.devexpress.com/OfficeFileAPI/17488/word-processing-document-api)
- [Spreadsheet Document API](https://docs.devexpress.com/OfficeFileAPI/14912/spreadsheet-document-api)
- [PDF Document API](https://docs.devexpress.com/OfficeFileAPI/16491/pdf-document-api)