In our work or study, we often want to use a function that we want to convert an HTML page into a PDF document. It's a common practice to copy this HTML page into a Word document in office, and then convert Word into a PDF document using the tool that comes with Word. We need to convert an HTML page or a piece of code that can render a process HTML page into a PDF page in our program, so what should we do? Here you can recommend an online website, https://pdfcrowd.com/html-to-pdf-api/, on this site, you can register a free account, this trial account can generate 100 PDF documents. The way API calls are very simple,
Step1. Register a user account with your own email address (e.g., Henryzhu), the registered mailbox will receive a value that uniquely identifies the user (for example, 096c8a2953b993db5b02341274393623).
Step2. Go to Https://pdfcrowd.com/static/clients/java/pdfcrowd-2.6-java.zip to download a jar package
Step3. Create an Eclipse project, add the downloaded package from the STEP2 to the build path, and then run the following instance code.
Import Com.pdfcrowd.*;import java.io.*;p ublic class Pdfcrowdtest {public static void main (string[] args) {try {FileOutputStream fileStream; Create an API client instance client client = new Client ("Henryzhu", "096c8a2953b993db5b02341274393623"); Convert a Web page and save the PDF to a file FileStream = new FileOutputStream ("Google_com.pdf"); Client.converturi ("http://www.google.com/", FileStream); Filestream.close (); Convert an HTML string and store the PDF into a byte array bytearrayoutputstream memstream = new Bytearrayo Utputstream (); String HTML = "