Last active
July 8, 2024 14:40
-
-
Save conholdate-gists/9e4318c0f2953ab8be8502e9396fcf0d to your computer and use it in GitHub Desktop.
Convert JSON to PDF in Java | JSON to PDF Converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a Workbook object | |
com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(); | |
// Access a worksheet | |
com.aspose.cells.Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Read JSON file | |
String fileName = "Data.json"; | |
String content = new String(Files.readAllBytes(Paths.get(fileName))); | |
// Set JsonLayoutOptions for formatting | |
com.aspose.cells.JsonLayoutOptions layoutOptions = new com.aspose.cells.JsonLayoutOptions(); | |
layoutOptions.setArrayAsTable(true); | |
// Import JSON data | |
com.aspose.cells.JsonUtility.importData(content, worksheet.getCells(), 0, 0, layoutOptions); | |
// Save JSON as PDF | |
workbook.save("output.pdf", com.aspose.cells.SaveFormat.AUTO); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment