Skip to content

How to Create a Thumbnail Image for Office Files using Cloudinary and Aspose

Many websites and mobile applications with user generated content allow you to upload all kinds of files. Images, PDFs, and Microsoft Office files, such as Word, Excel, and PowerPoint are all common types of uploads.

Web or mobile developers may want to build   applications that allow users to download PDFs, support document previews, or embed image thumbnails of Office files. However, implementing these types of capabilities can be quite a challenging task.

aspose

Aspose is one of the leading vendors that deals with file management APIs and conversion between different file formats. Having recently partnered with Aspose, we now offer an Aspose document conversion add-on. As a result, developers are able to upload Office files to Cloudinary, the same way as images, and convert them to PDF documents. Cloudinary can then convert the PDFs to images in order to display and embed them in websites, web applications or mobile apps. In addition, developers can use Cloudinary’s rich set of image transformation capabilities to match the converted images to their sites’ graphic design

aspose add-on

Cloudinary uses Aspose to convert Office files to PDFs. To break it down a bit, you can upload any raw files to Cloudinary, using the API and client libraries, by setting the resource_type upload parameter to raw. Then, in order to convert the files, just set the raw_convert parameter to aspose when uploading. That’s it!

Below is a code sample in multiple frameworks that shows how to upload a Word document and request a conversion to PDF using Cloudinary’s Aspose add-on.

Loading code examples

When the conversion is done, an image resource of the generated PDF is also created and stored in your Cloudinary account.

You can then deliver the PDF or further transform it as an image. For example, if a Word document was uploaded as a raw file, and was assigned with the public ID (the uploaded resource’s unique identifier) sample_document.docx, it would be available for CDN delivery using the following URL:

https://res.cloudinary.com/demo/raw/upload/sample_document.docx

Once the conversion is complete, a PDF ‘image’ file is available with a public ID same as the original document’s file name (e.g., sample_document.docx). The delivery URL in our example would be as follows:

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

Note that the conversion process is the same for Excel and PowerPoint files, as well.

The URL above is an example of Cloudinary URLs that are used to access converted files. They are quickly delivered fully optimized with the appropriate cache settings via Akamai’s CDN.

By leveraging Cloudinary’s various image transformation capabilities, you can convert and transform your generated PDF. Cloudinary supports transformations, such as extracting certain pages, resizing, cropping, creating thumbnails, converting to other formats (i.e. PNG, JPG and more), applying filters or effects, and more. Check out Cloudinary’s capabilities here.

For example, you can use Cloudinary to generate different sizes of thumbnails of your newly created PDF. Depending on your needs, you can set certain dimensions to fit your graphic design, such as width and height.

The 200×300 PNG thumbnail below was created using Cloudinary’s dynamic image transformation URL for the first page of the PDF document:

Loading code examples 300x200 PNG thumbnail

Another example, seen below, is a 200×200 JPEG thumbnail of the second page of the PDF document that was created, with increased saturation, sharpness, and a shadow:

Loading code examples 200x200 JPEG saturation increased sharpened thumbnail

Learn more about Cloudinary’s image transformation capabilities.

Cloudinary’s Aspose document conversion add-on asynchronously converts MS Office documents to PDFs. This means that once the documents are uploaded to Cloudinary, and the upload API is complete, Aspose can complete the conversion. This can take up to a few minutes depending on the size and content of the file. Since the conversion runs in the background, you might want to be notified when it is complete. Therefore, Cloudinary has [a background notifications and webhooks mechanism] (https://cloudinary.com/blog/webhooks_upload_notifications_and_background_image_processing), that sends an HTTP POST request to a notification URL that you provide when the operation is done.

See our documentation for more details about how to use the Aspose add-on.

Developers can use Cloudinary to allow their apps’ users to upload images and documents of any type. Together with the Aspose add-on you can now easily generate thumbnails from Office documents that can be embedded into your web or mobile applications. The Aspose add-on is available with all Cloudinary plans, including the free tier. You can try it out by subscribing to the free add-on plan.

Not using Cloudinary Yet? Sign up for a free Cloudinary account here.

Back to top

Featured Post