PDFTron is now Apryse. Same great products, new name.

Cross-Platform Word to PDF Conversion

By Aleksy Jones | 2015 Sep 08

Sanity Image
Read time

3 min

View and Convert Microsoft Word Documents Anywhere

We’re very pleased to announce the launch of the newest addition to Apryse SDK: built-in Word conversion. Now you can go straight from .docx to .pdf, free from the shackles of Microsoft Word or any other 3rd party software. Conversions are accurate and fast; they also work on any platform supported by Apryse SDK (and there are a lot of them! just select your platform when you start your free trial).

.docx file format shown on Word page full of text

Dependency-free Word conversion enables a couple of great use cases: you can perform reliable conversions in a server environment, or pair it with our PDF viewer for seamless viewing of .docx files on Android, iOS, and Windows Phone/RT.

Easy to Use, But Still Flexible

We’ve tried to strike a balance between power and simplicity in the API. The best way to demonstrate this is through a quick example: this small snippet demonstrates how to convert a Word document to a PDF (in Java).

// Start with a PDFDoc (the conversion destination)
PDFDoc pdfdoc = new PDFDoc();
// perform the conversion with no optional parameters
Convert.wordToPdf(pdfdoc, "input_file.docx", null);
// save the result
pdfdoc.save("output_file.pdf", SDFDoc.e_remove_unused, null);

That’s it, just 2.5 lines of code. Of course, maybe you would rather have more control over the conversion process. That’s possible too: the interface allows for cancellation, progress reporting, page-by-page conversion, and diagnostic messages (for example, information on font substitutions). Here is the same conversion, performed page-by-page and with progress reporting.

// get a DocumentConversion object, which encapsulates and controls
// the conversion process
DocumentConversion conversion = Convert.wordToPdfConversion(
    pdfdoc, "input_file.docx", options);
// convert each page, one-by-one, with progress reporting
while(conversion.getConversionStatus() == DocumentConversion.e_incomplete)
    System.out.println("Progress: " + (conversion.getProgress()*100.0) + "%");
// save the result
pdfdoc.save("output_file.pdf", SDFDoc.e_linearized, null);

To see these snippets as part of a fully working application, take a look at the OfficeToPDF sample project in the Apryse SDK.

No Fonts? No Problem

While fonts can be embedded within .docx documents, they typically aren’t. On a typical Windows system this isn’t a problem: the most common fonts in Word documents (Calibri, Times New Roman, Arial, Cambria, etc. ) are installed by default on every Windows system, and they can be used while converting or viewing the document.

On other systems, such as Linux servers or Android phones, these fonts are only available in special circumstances, and without them you would normally be limited to two options: a) distributing the original fonts alongside your app, or b) settling for poor conversion results.

With the PDFNet SDK, this is no longer the case: we employ a number of strategies to ensure that conversion remains faithful to the original — with content in the right place and on the right page — even when supplied with no external fonts at all. For a more practical and in-depth look at font-handling, see this knowledge base article.

Good, and Getting Better

We put a lot of work into our .docx converter. We’re very proud of this product, and we’re committed to improving it.

For the vast majority of documents created in a recent version of Word (Word 2010 or Word 2013, for example), the converter will yield excellent results, often indistinguishable from Word itself. Unfortunately, the .docx format is extensive and underspecified: the specification is more than 5000 pages, and is riddled with omissions and exceptions. There are bound to be features or behaviours that we have not quite nailed down. But that’s ok! We’re a small dev team and we move fast. If you’ve got a use case in mind, download our SDK and try it out. If something isn’t working for you, then let us know through our free trial support form, and chances are we’ll get it cleared up right away.

What About Powerpoint and Excel?

PowerPoint & Excel to PDF conversions are included in our Office to PDF Conversion SDK. Our SDK allows you to convert .docx, .doc, .xlsx and .pptx on any web, mobile, server or desktop software without users needing any MS Office software, MS Office licenses, or third-party open-source software. It also gives you the option to convert Office files to other files types like PDF, PDF/A, image file types, and more.

Give It a Try!

The built-in .docx conversion module is available as part of the Apryse SDK for Windows, Linux, Mac, Android, iOS, and UWP. To obtain a free trial, visit our downloads page.

The SDK download contains fully functional sample applications which demonstrate how to use the converter. Access our OfficeToPDF sample project and select your preferred language: C#, C# (.NET Core), C# (Xamarin), C++, Java, Java (Android), JavaScript, JS (Node.js), Kotlin, Obj-C, Swift or VB

Want More Information?

If you have technical questions visit our free trial support form or if would like information regarding licensing, please contact us. Your inquiry will be directed to a developer or our sales team, as appropriate.

Sanity Image

Aleksy Jones

Share this post