SampleFileAndOutput.zip (23.8 KB)
Aspose Team,
We use the Aspose PDF java package to convert html to pdf, and found out that the output is in text format (not in html presentation format) for the sample file.
Following is the sample code and attached is a sample file and the output pdf.
The operating system is Ubuntu 20.04. Java version is 17. Aspose PDF java packages is 23.10.
import com.aspose.pdf.Document;
import com.aspose.pdf.HtmlLoadOptions;
import java.nio.file.Paths;
public class HtmlToPdf_26_27 {
public static void main(String[] args) throws Exception {
try {
new com.aspose.pdf.License().setLicense("/home/ubuntu/QmulusWorker/required/Aspose.Total.Java.lic");
String htmlFile = "/home/ubuntu/testdirs/html_to_pdf/DmxNtvg0.html";
String pdfFile = "/home/ubuntu/testdirs/html_to_pdf/DmxNtvg0.html_pdf_out.pdf";
HtmlLoadOptions options = new HtmlLoadOptions();
Document pdfDocument = new Document(htmlFile, options);
pdfDocument.save(Paths.get(pdfFile).toString());
}
catch(Exception ex) {
ex.printStackTrace();
}
}