NOW AVAILABLE: Summer 2025 Release
By Garry Klooesterman | 2025 Sep 04
4 min
Tags
docx to pdf
Summary: Office file formats such as DOCX and XLSX aren’t always the best format for sharing or archiving. PDF is a more reliable format for sharing and PDF/A is designed for archiving long term. In this blog, we’ll look at how to convert DOCX and other Office file formats to PDF using the Apryse Office SDK and Java.
Office file formats such as DOCX and XLSX are common for both business and personal use, but they aren’t always the best format for sharing or archiving. PDF stands out as a much more reliable format for sharing as it will display the same regardless of the device used to open it and PDF/A is designed for long-term archival.
Apryse Office SDK offers built-in DOCX conversion allowing you to convert directly from DOCX to PDF, without the need for Microsoft Office or other third-party software. Accurately and quickly convert DOCX to PDF on any platform supported by the Office SDK.
Whether you’re converting files in a server environment or for use with a PDF viewer for seamlessly viewing DOCX files, our Office SDK makes the job easy. It’s available in various programming languages, including C#, C++, Java, and more.
Our API makes converting files to PDF easy with minimal code required. For example, the following code snippet will convert a DOCX file to PDF in Java.
Note: This is just the portion of the code required for converting the file. Check out the OfficeToPDF sample project in the Office SDK for the full code sample.
// Start with a PDFDoc (the conversion destination)
PDFDoc pdfdoc = new PDFDoc();
// perform the conversion with no optional parameters
Convert.officeToPdf(pdfdoc, input_path + inputFilename, null);
// save the result
pdfdoc.save(output_path + outputFilename, SDFDoc.SaveMode.INCREMENTAL, null);
That’s it, just a few lines of code. If you'd prefer to have more control over the conversion process, the code also allows for cancellation, progress reporting, page-by-page conversion, and diagnostic messages (for example, information on font substitutions).
In this example, we can see the same conversion as the one we did earlier, but it also includes page-by-page conversion and progress reporting.
Note: Here again is just the portion of the code required for converting and saving the file. Check out the OfficeToPDF sample project in the Apryse Office SDK for the full code sample.
// create a conversion object -- this sets things up but does not yet
// perform any conversion logic.
// in a multithreaded environment, this object can be used to monitor
// the conversion progress and potentially cancel it as well
DocumentConversion conversion = Convert.streamingPdfConversion(
input_path + inputFilename, options);
System.out.println(inputFilename + ": " + Math.round(conversion.getProgress() * 100.0)
+ "% " + conversion.getProgressLabel());
// actually perform the conversion
while (conversion.getConversionStatus() == DocumentConversion.e_incomplete) {
conversion.convertNextPage();
System.out.println(inputFilename + ": " + Math.round(conversion.getProgress() * 100.0)
+ "% " + conversion.getProgressLabel());
}
// save the result
try (PDFDoc doc = conversion.getDoc()) {
doc.save(output_path + outputFilename, SDFDoc.SaveMode.INCREMENTAL, null);
}
While you can embed fonts within DOCX documents, this is not typically done. In most Windows systems, the most commonly used fonts in Word documents such as Calibri, Times New Roman, Arial, and Cambria, are installed by default, and are used while converting or viewing the document.
Other systems like Linux servers or Android phones may not have these fonts installed and without them, your options are limited to the following:
With our Office SDK, the conversion remains faithful to the original, keeping the content in the right place and on the right page. If external fonts are not provided, the converter will attempt to use any fonts installed on the system. Fonts and alternatives can also be set up in the code. For more details on adding font resources, see our documentation.
Our Office SDK includes the ability to convert PowerPoint and Excel files as well. You can convert DOCX, XLSX, and PPTX files to PDF on practically any web, mobile, server, or desktop software without the need for Microsoft Office software, Microsoft Office licenses, or third-party software. You can also convert Office files to other file types including PDF, PDF/A, or images.
Is Microsoft Office required to convert files using the Apryse Office SDK?
No. Apryse Office SDK converts Office files without the need for Microsoft Office or other third-party software.
Can I convert more than just DOCX files to PDF?
Yes. The Office SDK allows you to convert DOCX, DOC, XLSX, and PPTX to PDF.
Will the conversion be the same from one platform to another?
Yes. The Office SDK is independent of the OS, resulting in the same conversion no matter which OS you run it on.
Is Apryse Office SDK free to use?
You can obtain a free trial key to get started and try it out. We also offer flexible licensing.
Is Apryse Office SDK available in programming languages other than Java?
Yes. Apryse offers SDKs in various programming languages including JavaScript, C++, and C#.
As you’ve seen, converting DOCX, or any other Office file format, to PDF, requires just a few lines of code when using the Apryse Office SDK and the included DOCX conversion module. The Office SDK is available for Windows, Linux, Mac, Android, iOS, and UWP.
For fully functional sample applications that show how to use the converter, check out our OfficeToPDF sample project and select your preferred language.
Try it out for yourself with our live demo or get started now. You can also contact our sales team for any questions and for support and discussions, check out our Discord community.
Tags
docx to pdf
Garry Klooesterman
Senior Technical Content Creator
Share this post
PRODUCTS
Platform Integrations
End User Applications
Popular Content