Importing HTML into InDesign
What to Import?
We have recently been looking at finding a way of importing HTML files easily into InDesign. This certainly is not an easy task because HTML files have been created specifically with an online purpose while InDesign is really intended primarly for print output. For example images that may have a 72 dpi resolution in the <img> tags are not suitable for print. It is primarily text based elements in the HTML file(including tables) that will be most useful for import.
Some of the Issues
One of the issues with attempting to convert from CSS is that it most often than not does not specify any values, but relies on set defaults. InDesign styles specify values for style attributes in the InDesign interface. The styles for tags can either be set directly or through classes. Any plug-in or script attempting to reproduce the styles would need to be able to reproduce the defaults and then see when they are modified in the CSS code. A much better solution might be to just create a set of styles in an InDesign template with a matching system to match InDesign styles to HTML tags and CSS classes. However it could also be really useful to have some generation functionality to create the Paragraph Styles in InDesign and specifically ensure that we actually always have a match between the tags and styles in the HTML and the InDesign document.
CSS Defaults for Text
This is an example of CSS and InDesign default matching for CSS text based attributes:
CSS Property | Default Value | InDesign Property | InDesign Default Value |
---|---|---|---|
font-family | sans-serif | fontFamily | Arial |
font-size | 16px | fontSize | 12pt |
color | black | fillColor | Black |
line-height | normal | leading | Auto |
text-align | left | justification | LeftAlign |
text-transform | none | capitalization | Normal |
font-weight | normal | fontStyle | Regular |
font-style | normal | fontStyle | Regular |
text-decoration | none | underline | None |
letter-spacing | normal | kerning | Auto |
font-family | Any font name (e.g. “Arial”, “Helvetica”, “Times New Roman”) or a list of font names separated by commas (e.g. “Arial, sans-serif”). The browser will use the first available font in the list. The default value is “sans-serif”. |
font-size | Any valid CSS length value (e.g. 10px, 12pt, 2em). The default value is 16px. |
color | Any valid CSS color value (e.g. red, #ff0000, rgb(255, 0, 0)). The default value is black. |
line-height | Any valid CSS length value or a percentage of the font size (e.g. 1.5, 150%). The default value is normal, which is equivalent to a line height of 1.2 in most browsers. |
text-align | left, right, center, justify. The default value is left. |
text-transform | none, uppercase, lowercase, capitalize. The default value is none. |
font-weight | normal, bold, bolder, lighter, or a number between 100 and 900 in increments of 100 (e.g. 400, 700). The default value is normal. |
font-style | normal, italic, oblique. The default value is normal. |
text-decoration | none, underline, overline, line-through. The default value is none. |
letter-spacing | Any valid CSS length value (e.g. 1px, 2pt, 0.1em). The default value is normal, which is equivalent to a letter spacing of 0 in most browsers. |