Programmable Media

Aspose Document Conversion

Last updated: Jun-17-2024

Cloudinary is a cloud-based service that provides an end-to-end image management solution including uploads, storage, transformations, optimizations and delivery.

Cloudinary offers a rich set of image transformation and format conversion capabilities. Cloudinary allows you to upload images and non-image raw files to the cloud. Images and PDF files can be converted to various image formats and can be cropped on the fly and further transformed to match the graphic design of your websites and mobile applications.

Aspose is a leading vendor of development components, including a powerful set of file management and conversion products. Cloudinary provides an add-on for using Aspose's Office document conversion capabilities, fully integrated into Cloudinary's image management and transformation pipeline.

With Aspose's Document Conversion add-on, you can extend Cloudinary's powerful format conversion and image transformation capabilities with automatic conversion of your Microsoft Office documents, spreadsheets and presentations to PDF documents and image thumbnails.

Getting started

Before you can use the Aspose Document Conversion add-on:

  • You must have a Cloudinary account. If you don't already have one, you can sign up for a free account.

  • Register for the add-on: make sure you're logged in to your account and then go to the Add-ons page. For more information about add-on registrations, see Registering for add-ons.

  • Keep in mind that many of the examples on this page use our SDKs. For SDK installation and configuration details, see the relevant SDK guide.

  • If you're new to Cloudinary, you may want to take a look at the Developer Kickstart for a hands-on, step-by-step introduction to Programmable Media features.

Convert Office documents

When you apply the Aspose add-on while uploading or updating a Microsoft Office file, the add-on converts the file to an image of type PDF and stores the converted file in addition to your original raw Office file.

Notes
  • Make sure to embed any custom fonts in the original file.
  • The Aspose add-on supports converting files up to 10 MB.

Supported Office file formats

The following Office file formats are supported:
doc, docx, docm, dotx, rtf, txt, xls, xlsx, xlsm, pot, potm, potx, pps, ppsm, pptx, ppt, and pptm.

Converting Office files on upload

To convert a document using the Aspose add-on while uploading the original Office file, set the raw_convert parameter of your upload command to aspose. Additionally, make sure to set resource_type parameter to either raw or auto (instructing Cloudinary to automatically detect that the file is a non-image raw file).

Tip
You can use upload presets to centrally define a set of upload options including add-on operations to apply, instead of specifying them in each upload call. You can define multiple upload presets, and apply different presets in different upload scenarios. You can create new upload presets in the Upload Presets page of the Console Settings or using the upload_presets Admin API method. From the Upload page of the Console Settings, you can also select default upload presets to use for image, video, and raw API uploads (respectively) as well as default presets for image, video, and raw uploads performed via the Media Library UI.

Learn more: Upload presets

Document conversion using the Aspose add-on is performed asynchronously in the background after the upload call is completed. Therefore, the response of the uploaded request mentions that the Aspose raw convert process is in the pending status.

As a result of the upload example above, the uploaded Microsoft Office (raw) file with the public ID of 'sample_document.docx', is immediately available for delivery as-is using the following CDN URL:

When the Aspose document conversion is completed, a new PDF asset with delivery type image is also created in your product environment. The image asset has the same public ID as the uploaded raw document, including the extension: 'sample_document.docx' in the above example. Because it is now an image (PDF), you can transform and deliver the generated image resource in any image format, the same way you would transform any standard image that was uploaded to Cloudinary.

The following sample code creates an HTML image tag with a Cloudinary URL that generates a PNG image of the uploaded Word document.

PNG image of the document

Converting existing Office files

You can convert previously uploaded Office documents using the update Admin API method while specifying the public ID of a previously uploaded Office file and setting raw_convert to aspose.

Monitor the webhook notification

The Aspose add-on converts documents asynchronously. The conversion usually takes a few seconds, but the conversion time is dependent on the size and complexity of the converted document. As a result, you may want to get notified when the conversion process is completed.

When calling the upload or update API with aspose document conversion, you can set the notification_url parameter to a public HTTP or HTTPS URL endpoint of your online web application. Cloudinary sends a POST request to the specified endpoint when the document conversion completes.

The following JSON snippet is an example of a POST request sent to the notification URL when the document conversion is completed:

The JSON content is signed using your Cloudinary product environment API secret. For details, see Verifying notification signatures

Deliver PDFs and images of Office documents

The Aspose add-on automatically converts raw Office documents to PDF files. You can deliver the converted PDF as you would any other PDF using Cloudinary's CDN delivery URLs. The following code example returns the PDF delivery URL of the converted Word document.

The returned URL: https://res.cloudinary.com/demo/image/upload/sample_document.docx.pdf

You can also apply a variety of transformations on PDF documents. For example, the following code creates an HTML image tag with a dynamic transformation URL that generates a small JPG 'thumbnail' image of the second page (pg_2) of the document.

Page 2 scaled down

Important note for free accounts:
By default, Free accounts are blocked from delivering files in PDF format for security reasons.
For details, see Media delivery.

Apply additional image transformations

Office document conversion using the Aspose add-on can be combined with other image transformation capabilities.

For example, the following code scales down the fourth page of the processed Word document to a width of 300 pixels while rounding its corners, applying the sepia effect and adding a gray background. Then another uploaded image named aspose_cloud_logo is added as an overlay. The overlay is resized to a relative width of 90% of the underlying image, positioned 20 pixels from the bottom of the containing image and is made 70% semi transparent.

PNG of spreadsheet

To learn more about all available image transformation options, see Image transformations and the Transformation URL API Reference.

✔️ Feedback sent!

Rate this page: