Skip to content

Instantly share code, notes, and snippets.

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/
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