DEV Community

Cover image for Create a Web API Application with our Office File API (Powered by the platform-agnostic DevExpress.Drawing Graphics Engine)
Poline for DevExpress Technical

Posted on • Originally published at

Create a Web API Application with our Office File API (Powered by the platform-agnostic DevExpress.Drawing Graphics Engine)

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
  2. Reporting
  3. BI 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 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. 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 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

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 or DevExpress Universal Subscription)

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

web api main view

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

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

web api result

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

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:

Top comments (0)