Resolution Included in Image Files

This section provides a tutorial example to demonstrate the logic used by XSL processors to determine to determine the image display resolution. Resolution information included in the image file will be respected, if 'scale-to-fit' is not specified.

Another factor to consider when managing graphics resolution is the resolution information included in the graphics file itself. Here is the common logic an XSL processor follows to determine the final resolution:

Let's assume that I have a tangram image of 120x120 pixel stored in 2 files: Tangram-120-DPI.jpg with 120 DPI resolution properties included, and Tangram-No-DPI.gif with no resolution properties included. Here is my tutorial example, external-graphic-Resolution-Rules.fo, that displays the tangram image with different attributes:

<?xml version="1.0" encoding="utf-8"?>
<!-- external-graphic-Resolution-Rules.fo
 - Copyright (c) 2016, HerongYang.com, All Rights Reserved.
-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master master-name="page" 
   margin="0.1in" page-height="6in" page-width="3.5in">
   <fo:region-body region-name="body" background-color="#eeeeee"/>
  </fo:simple-page-master>
 </fo:layout-master-set>
 <fo:page-sequence master-reference="page">
  <fo:flow flow-name="body">
    <fo:block-container width="1in" border-width="1px"
     border-style="solid">
     <fo:block>1 inch</fo:block>
    </fo:block-container>
    <fo:block-container width="72px" border-width="1px" 
     border-style="solid">
     <fo:block>72 px</fo:block>
    </fo:block-container>
    <fo:block-container width="120px" border-width="1px" 
     border-style="solid">
     <fo:block>120 px</fo:block>
    </fo:block-container>
   <fo:block-container border-width="1px" border-style="solid">
    <fo:block>Resolution overridden: 144 DPI</fo:block>
    <fo:block>
     <fo:external-graphic width="0.83in" height="0.83in" 
      content-width="scale-to-fit" content-height="scale-to-fit"
      src="url('Tangram-120-DPI.jpg')"/>
    </fo:block>
   </fo:block-container>
   <fo:block-container border-width="1px" border-style="solid">
    <fo:block>Resolution from image file: 120 DPI</fo:block>
    <fo:block>
     <fo:external-graphic src="url('Tangram-120-DPI.jpg')"/>
    </fo:block>
   </fo:block-container>
   <fo:block-container border-width="1px" border-style="solid">
    <fo:block>Resolution from default: ? DPI</fo:block>
    <fo:block>
     <fo:external-graphic src="url('Tangram-No-DPI.gif')"/>
    </fo:block>
   </fo:block-container>
  </fo:flow>
 </fo:page-sequence>
</fo:root>

If you process this example XSL-FO document with Apache FOP tool, you should see the tangram image displayed 3 times in different sizes:

"external-graphic" Resolution Rules - Apache FOP

Note that:

Exercise: process this example XSL-FO document with RenderX XEP tool to see the impact of XSL processor default resolution on the third tangram.

Last update: 2016.

Table of Contents

 About This XSL-FO Tutorial Book

 Introduction of XSL-FO

 Apache™ FOP (Formatting Objects Processor)

 RenderX XEP as an XSL-FO Tool

 Introduction of Area Model

 XSL-FO Document Basics and Examples

 Page Layout Masters

 Block-Level Formatting Objects

 Inline-Level Formatting Objects

Including Graphics in XSL-FO document

 What Is "external-graphic" Formatting Object?

 Control DPI with "content-width" and "content-height"

 Fixed Higher DPI with "scale-to-fit"

Resolution Included in Image Files

 Image Over and Under Flow Area

 "external-graphic" with SVG Diagram

 "instream-foreign-object" Formatting Object

 Table of Rows and Columns

 List, Item, Label, and Body

 Floating Blocks - "float" and "footnote"

 Hyperlinks, Table of Contents and Indexes

 Headers and Footers using "static-content"

 Font Attributes and Font Families

 Apache FOP Font Configurations

 RenderX XEP Font Configurations

 References

 PDF Printing Version