Last active
March 31, 2023 18:07
How to Convert HTML to PDF using Java. For more information: https://kb.aspose.com/pdf/java/how-to-convert-html-to-pdf-using-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
import com.aspose.pdf.*; | |
public class Main { | |
public static void main(String[] args) throws Exception {//Convert HTML to PDF | |
// Load a license | |
License lic = new License(); | |
lic.setLicense("Aspose.Total.lic"); | |
// Instantiate the HtmlLoadOptions object | |
HtmlLoadOptions options = new HtmlLoadOptions(); | |
// Load the source HTML using the specified options | |
Document pdfDocument = new Document("sample.html", options); | |
// Save the output PDF | |
pdfDocument.save("output.PDF"); | |
System.out.println("Done"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment