Skip to content

Instantly share code, notes, and snippets.

How to Convert DOC to DOCX using Java. For more information, please follow link: https://kb.conholdate.com/total/java/how-to-convert-doc-to-docx-using-java
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.licensing.License;
import com.groupdocs.conversion.options.convert.WordProcessingConvertOptions;
public class ConvertDocToDocxUsingJava {
public static void main(String[] args) { // Main function to convert DOC to DOCX in Java
// Remove the watermark in output DOCX document by adding license
License lic = new License();
lic.setLicense("/path/to/GroupDocs.Conversion.lic");
// Load the source DOC file for conversion to DOCX
Converter converter = new Converter("/path/to/sample.docx");
// Set the convert options for DOCX format
WordProcessingConvertOptions options = new WordProcessingConvertOptions();
// Convert and save the DOC in DOCX format
converter.convert("/path/to/converted.doc", options);
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment