Convert HTML Files, Strings, and URLs to TIFF
Aspose.HTML for Python via .NET
converts an HTML file, string, document, or URL to TIFF with
Converter.convert_html()
and
ImageSaveOptions
. Set ImageFormat.TIFF explicitly because the image options use PNG by default.
TIFF output is useful when a document-imaging or print workflow needs raster pages and configurable lossless compression. The conversion rasterizes the HTML layout, so the result preserves page appearance rather than editable HTML structure.
Generate TIFF Files and Matching Python Code
Add an HTML file or webpage URL, then keep TIFF selected to generate a raster page image. The widget displays Python code for the selected source and output format.
{{#if_output 'PDF' 'DOCX' 'XPS' 'MHTML' 'MD' }}
import aspose.html as ah
import aspose.html.converters as conv
import aspose.html.saving as sav
{{/if_output}}
{{#if_output 'BMP' 'JPEG' 'GIF' 'PNG' 'TIFF' 'WEBP'}}
import aspose.html as ah
import aspose.html.converters as conv
import aspose.html.rendering.image as rim
import aspose.html.saving as sav
{{/if_output}}
{{#if_output 'XHTML'}}
import aspose.html as ah
import aspose.html.saving as sav
{{/if_output}}
with ah.HTMLDocument("{{input lower}}") as document:
{{#if_output 'PDF'}}
options = sav.PdfSaveOptions()
{{/if_output}}
{{#if_output 'DOCX'}}
options = sav.DocSaveOptions()
{{/if_output}}
{{#if_output 'XPS'}}
options = sav.XpsSaveOptions()
{{/if_output}}
{{#if_output 'BMP' 'JPEG' 'GIF' 'PNG' 'TIFF' 'WEBP'}}
options = sav.ImageSaveOptions(rim.ImageFormat.{{output param2 upper}})
{{/if_output}}
{{#if_output 'MHTML'}}
options = sav.MHTMLSaveOptions()
{{/if_output}}
{{#if_output 'MD'}}
options = sav.MarkdownSaveOptions.default
{{/if_output}}
{{#if_output 'BMP' 'JPEG' 'GIF' 'PNG' 'TIFF' 'WEBP' 'PDF' 'MHTML' 'MD' 'XPS' 'DOCX'}}
conv.Converter.convert_html(document, options, "output.{{output lower}}")
{{/if_output}}
{{#if_output 'XHTML'}}
options = sav.HTMLSaveOptions()
options.document_type = sav.HTMLSaveOptions.XHTML
document.save("output.xhtml", options)
{{/if_output}}
For TIFF output, the generated example creates ImageSaveOptions with ImageFormat.TIFF and writes output.tiff. Configure compression, page dimensions, and resolution before calling the converter when the defaults do not match the target imaging workflow.
Python Code to Convert HTML to TIFF
import aspose.html as ah
import aspose.html.converters as conv
import aspose.html.rendering.image as rim
import aspose.html.saving as sav
with ah.HTMLDocument("document.html") as document:
options = sav.ImageSaveOptions(rim.ImageFormat.TIFF)
conv.Converter.convert_html(document, options, "output.tiff")
Convert an HTML Document to TIFF in Python
- Install the
aspose-html-netpackage. - Open the HTML file or webpage URL in
HTMLDocument. Provide a base URI when HTML text refers to relative resources. - Create
ImageSaveOptionsand selectImageFormat.TIFF. - Choose the TIFF compression, page dimensions, resolution, and background required by the destination system.
- Call
Converter.convert_html()with the document, options, and.tiffoutput path.
Choose TIFF Compression for HTML Output
The compression setting affects TIFF encoding and file size without changing the HTML layout. Choose a method that matches the color model and requirements of the downstream imaging system.
| Compression | Suitable content | What to consider |
|---|---|---|
Compression.LZW | Color pages, text, diagrams, and mixed document content. | Lossless LZW is the default TIFF compression and is the general starting point. |
Compression.CCITT3 or Compression.CCITT4 | Bilevel document-imaging workflows. | Use these methods only when the expected TIFF workflow is monochrome and supports the selected encoding. |
Compression.RLE | Images with repeated runs of similar pixels. | Check compatibility and resulting file size in the receiving application. |
Compression.NONE | Workflows that explicitly require uncompressed TIFF data. | Uncompressed output can be significantly larger than lossless compressed output. |
Set TIFF Page Size, Resolution, and Background
After selecting TIFF compression, use ImageSaveOptions to configure the output pages:
- Page setup: Set page dimensions and margins to control pagination and the raster canvas for each output page.
- Resolution: Horizontal and vertical resolution determine the pixel density of pages defined in physical units. Pixel-based page dimensions already define their raster size directly.
- Background: Choose the page fill required by the TIFF viewer, archive, print process, or downstream image tool.
- Image processing: Configure antialiasing and text hinting when edges or glyph placement need adjustment.
- Resources and fonts: Resolve relative paths from the source location or a base URI, keep remote assets accessible, and install required local fonts before conversion.
- Loaded document state: Convert the content available after loading. Later user interaction is not reproduced in the TIFF pages.
See Convert HTML to Image in Python for shared image settings and HTML Rendering Options for TIFF compression and raster-rendering details.
Install Aspose.HTML for Python via .NET
Install the aspose-html-net package from
PyPI
.
Install Aspose.HTML for Python via .NET
pip install aspose-html-net
Review the installation guide and system requirements before deployment. Request a temporary license to test the API without evaluation limitations.
HTML to TIFF FAQ
1. Does HTML to TIFF conversion create one multipage TIFF file?
The standard output-path workflow creates page-based image output rather than one multipage TIFF container. When the converted document spans several pages, the converter writes separate numbered TIFF files. Configure page dimensions or the source layout when one page image is required.
2. Does a higher DPI setting make every HTML to TIFF image sharper?
Higher DPI creates more pixels when the page uses physical units such as inches or millimeters. It does not enlarge a page already sized in pixels or restore detail missing from a low-resolution source image.
3. Does HTML to TIFF conversion preserve selectable text and hyperlinks?
No. HTML to TIFF conversion rasterizes the page. Text, links, and controls become pixels and do not remain selectable or interactive in the TIFF image.
TIFF and Document Image Conversion Guides
Compare TIFF with other page-image formats or return to the complete Python conversion catalog.