Report Word --> PDF conversion via Aspose API instead of OpenOffice

Hi,

recently I created an example on how to use Aspose Cloud Words API in order to do a docx → PDF conversion. Here’s the how to:

Github: GitHub - mariodavid/cuba-example-aspose-api: cuba-platform cuba-example

CUBA example - converting DOCX to PDF with Aspose Cloud

This example shows how to integrate Aspose Words Cloud in order to generate a PDF file out of a word document (docx) via its cloud API.

What is the problem with DOCX to PDF

Basically the accuracy of the result. Dealing with images, tables layers, columns, shapes etc. oftentimes leads to inaccurate results in the target PDF file depending on what technology is used for doing the conversion.

CUBA Reports requires an OpenOffice server

The reports engine from CUBA normally solves this inaccuracy problem by using an external OpenOffice server, that is doing the transformation. The accuracy is quite good there, much better as just using alternatives like docx4j directly.

But having OpenOffice on a server running sometimes leads to problems. Communication between the two applications is done via TCP sockets. Sometimes the connections are not cleaned up correctly. Also there is the potential problem, that there are memory problems with Open / LibreOffice. Also the software has to be updated, it has to made sure
that the new version is really compatible with the used CUBA application etc.

So, bottom line: there are a lot of things to consider.

Externalizing the PDF generation

An alternative is that CUBA reports is just for “docx template” → “docx document” generation, but the “docx document” → “PDF document” is externalized to an cloud based API.

Aspose Words Cloud API is an cloud service, that allows to programmatically generate PDF files out of a word document (among a lot of other things).

Converting DOCX to PDF via Aspose

In this example it is shown on how to interact with the Aspose Cloud offering via its SDK.

Results

The results can be found in the example-files directory. The results are almost 100% identical (which really surprised me). I intentionally took a lot of examples with complex layouts & images in place.

Application Overview

overview

Comparing Results

3 Likes

It is worth mentioning that:

  1. Aspose is just an example of various available SaaS offerings
  2. Aspose is payed offering with a pay per use model

The guide is more about the idea of offloading the PDF generation as an alternative.

Bye
Mario

Hi @mario

Very interesting.

It happens that in our project we just reached a point where we are facing the same question. The problems you list with using OpenOffice are so real : it’s slow, it crashes sometimes, it has weird errors in log, and we have some xls templates with borders that simply do not work.

So we have to decide if we keep generating reports with xls templates, then use a 3rd party tool to convert to pdf like you expose. Or (my preference) get rid completely of OpenOffice by generating html (using Jasper template) and convert to pdf using iText or Apache pdfbox.

Do you (or someone else in the audience) have experience with these tools ? We’ll conduct tests of our own of course, but getting feedback could be precious. Especially if I’m told that we could be not satisfied of the results.

Best Regards
Michael