• Pricing
  1. Home
  2. PDF Converter
  3. How to Convert PDF Documents
  4. How to Convert HTML with Images to PDF Without Losing Formatting

How to Convert HTML with Images to PDF Without Losing Formatting

by David Beníček

Need to convert HTML with images to PDF without ending up with a broken layout or missing pictures? Here’s a step-by-step guide to getting it done.

Need to convert HTML with images to PDF without ending up with a broken layout or missing pictures? Here’s a step-by-step guide to getting it done.

When you save a webpage or HTML document as a PDF, you don’t just want the words—you want everything to look exactly as it should. That means keeping images in the right spots, maintaining fonts and colors, and avoiding weird spacing issues. If a quick save leaves you with misplaced images or formatting problems, you may need to tweak the file afterward. A helpful option is to convert HTML with images to PDF first, then refine the layout using a PDF converter to work with the file in Word, Excel, or PowerPoint.

Printing HTML to PDF for a Quick and Simple Solution

If you just need a fast, no-fuss way to convert HTML with images to PDF, your web browser’s built-in “Save to PDF” option can do the job.

  1. Open the HTML page in Chrome, Edge, Safari, or Firefox.
  2. Press Ctrl + P (Windows) or Cmd + P (Mac) to open the print menu.
  3. Choose "Save as PDF" as your printer.
  4. Click “More settings” to adjust margins, paper size, and image quality.
  5. Hit “Save,” choose a file name, and you’re done.

This method is fast and easy, but it has its limits. Sometimes, images get chopped off, text doesn’t wrap correctly, or interactive elements disappear.

Enhancing Your PDF After Conversion

Even after you’ve converted your HTML to PDF with images, you might need to make a few finer adjustments to ensure the file looks perfect.

Refining Your PDF with Smallpdf

If the formatting is slightly off or the images look blurry, Smallpdf’s PDF Converter can help refine the file.

  1. Upload your document to our PDF Converter.
  2. Choose the format you want to convert to—Word, Excel, PowerPoint, or even an image.
  3. Download the converted document and open it.

Now you can edit the document as much as you want to, from adjusting margins, to changing fonts, colors, and more. If the images are still fuzzy, try copying the image from the website and pasting them into your converted document. You will need to adjust the size, but the image should be sharp again.

Making image adjustments in Word after using PDF Converter

Making image adjustments in Word after using PDF Converter

If you notice that images have shifted out of place or text isn’t wrapping properly, right-click on the image and choose “Size and Position…” This will allow you to precisely position the image and how it wraps around text.

Embedding and Displaying PDFs as Images in HTML

Sometimes, instead of converting an HTML page into a PDF, you may need to display a PDF as an image in HTML. This can be useful when embedding PDFs on a website, giving users a preview of the document without them having to open it first.

Displaying a PDF as an Image in HTML

One way to do this is by converting a PDF into an image file, like PNG or JPG using PDF Converter, and then embedding it using an img tag:

HTML code to display a PDF as an image on a web page

HTML code to display a PDF as an image on a web page

This works well for static content, but the image quality might drop if the resolution isn’t high enough.

Embedding a PDF

If you want to embed a full PDF in your webpage, you can use the iframe tag:

HTML code to embed a PDF in a web page

HTML code to embed a PDF in a web page

This allows users to view the entire PDF within the page instead of downloading it. However, keep in mind that some browsers handle PDFs differently, and mobile users may experience display issues.

Keeping Image Quality Intact

If you're converting a PDF into an image before embedding, using a high-resolution format is key. PNG files work well for sharpness, while JPG files keep the file size smaller. It’s also a good idea to test how the embedded file appears on different devices to make sure it displays correctly.

Choosing the Best Method for Your Needs

Different methods work best for different situations, so choosing the right one depends on what you need.

And if you need a final touch-up after converting HTML to PDF, Smallpdf’s tools can help clean up any formatting issues and adjust layouts. No matter which method you choose, you want to ensure the final PDF keeps both images and formatting intact for maximum impact.

David Beníček – Product & Engineering Manager
David Beníček
Product & Engineering Manager @Smallpdf