We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Html to pdf conversion hung if images are present

  1. A very simple source html file source.html
<!DOCTYPE html>
    <div class="header">
      <h1>My Website</h1>
      <p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolorum molestias, ipsam asperiores illum repudiandae nesciunt, est dolorem quia cupiditate suscipit voluptatum iure autem non libero doloremque mollitia rem aliquid veritatis?</p>
      <div class="site-logo">
        <img src="https://www.gettyimages.in/gi-resources/images/Embed/new/embed2.jpg" alt="logo"/>
  1. Maven dependency
  1. Java code to convert html to pdf

	public static void main(String[] args) {

	private static void convert() {
		MarginInfo marginInfo = new MarginInfo();
		PageInfo pageInfo = new PageInfo();

		// Create a HTML LoadOptions
		HtmlLoadOptions options = new HtmlLoadOptions();
		// Initialize document object
		String htmlFileName = Paths.get("source.html").toString();
		Document document = new Document(htmlFileName, options);

		// Save output PDF document

“Done” never prints (unless the div containing the img is removed from source.html) and the program just hangs. What am I missing? Would appreciate some help to get this very simple conversion to work.

  1. My environment
$ java --version
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

$ javac --version
javac 11.0.13


We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFJAVA-41183. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

1 Like