Options for converting Word documents to PDF

Fairly new using Lucee in production. Ran into an issue this week while converting uploaded documents to PDF. The problem is with converting Microsoft documents like Word .doc and .docx files. I found in the Lucee docs that these are not supported with the PDF extension.

What are you all using to convert Microsoft documents to PDF with Lucee? I’d like to be able to use something that integrates well with Lucee so we can continue with minimal (if any) code changes. Currently using the <cfdocument format="pdf" srcfile="worddoc.docx" filename="newdoc.pdf" overwrite=true fontembed="true"></cfdocument> tag to do these conversions where we have a Word document already and trying to convert them to PDF. Worked fine with Adobe CF.

Windows Server 2019
JavaVersion: 11.0.20
Apache Tomcat/9.0.78
Lucee stable 5.4.4.38

1 Like

My current approach to converting Word to PDF is to use LibreOffice via command line. The environment is Windows Server 2019, Java 11.0.22, Tomcat 9.0.84, Lucee 5.4.4.38. Here is an example.

<cftry>
	<cfexecute name='C:\Program Files\LibreOffice\program\soffice.exe' arguments='--headless --convert-to pdf:writer_pdf_Export --outdir "C:\Temp\pdfdoc.pdf" "C:\docs\worddoc.docx"' timeOut='20' variable='cmdresult'></cfexecute>
	<cfset wait = Sleep(10000)>
	<cfcatch type="Any">
		<!---  --->
	</cfcatch>
</cftry>

I would welcome a better method of converting Word to PDF.

2 Likes

My understanding of Maven is next to null, but this shows promise and Ill tinker around with it as time allows…

The package for Java to open a word file
https://www.docx4java.org

The how To Use /

once you successfully get this working, you can get Lucee to output any content to a pdf