Read the complete article on how to convert text to PNG, JPEG, and GIF images in Java: https://blog.aspose.com/2022/06/06/convert-text-to-image-in-java/
Last active
June 6, 2022 11:31
-
-
Save aspose-com-gists/3c0852b11533f8444cc7bdd3b579ff85 to your computer and use it in GitHub Desktop.
Convert Text to PNG, JPEG, or GIF Image in Java
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
// Load text file | |
Document doc = new Document("Input.txt"); | |
// Loop through each page | |
for (int page = 0; page < doc.getPageCount(); page++) { | |
// Extract the page | |
var extractedPage = doc.extractPages(page, 1); | |
// Save as image, e.g. PNG | |
extractedPage.save("Output_" + page + ".png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment