Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert doc to pdf using Java
This Gist contains code snippets related to conversion DOC file to PDF using Aspose.Words Cloud SDK for Java
// Get clientId and clientSecret from
String clientId = "718e4235-8866-4ebe-bff4-f5a14a4b6466";
String clientSecret = "388e864b819d8b067a8b1cb625a2ea8e";
// if baseUrl is null, WordsApi uses default
// create an object of ApiClient by providing user specific ClientID and Client Secret
ApiClient apiClient = new ApiClient(clientId,clientSecret,null);
// create an object of WordsApi by providing ApiClient as argument
WordsApi wordsApi = new WordsApi(apiClient);
// input Word document path
String inputFileName = "/Users/nayyershahbaz/Downloads/TableDocument.doc";
// resultant file format
String format = "pdf";
// Create an instance of ConvertDocumentRequest
ConvertDocumentRequest request = new ConvertDocumentRequest(Files.readAllBytes(Paths.get(inputFileName)), format, "Converted.pdf", null, null, null);
// perform document conversion
File result = wordsApi.convertDocument(request);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment