Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active July 12, 2021 20:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save aspose-cloud/bfd7ce54d8259595ca50bce527f7930a to your computer and use it in GitHub Desktop.
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 https://dashboard.aspose.cloud/
String clientId = "718e4235-8866-4ebe-bff4-f5a14a4b6466";
String clientSecret = "388e864b819d8b067a8b1cb625a2ea8e";
// if baseUrl is null, WordsApi uses default https://api.aspose.cloud
// 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