"instream-foreign-object" Formatting Object

This section describes the 'instream-foreign-object' formatting object, which is used to take embedded object to generate an inline area. It is mostly used to embed SVG diagrams.

What Is an "instream-foreign-object" Formatting Object? "instream-foreign-object" is an inline-level formatting object that takes an embedded XML structure to generate an inline area.

An "instream-foreign-object" formatting object supports the following main attributes:

Here is my tutorial example, instream-foreign-object-SVG.fo, that shows an "instream-foreign-object" formatting object inserting a SVG diagram with an embedded SVG XML sub structure:

<?xml version="1.0" encoding="utf-8"?>
<!-- instream-foreign-object-SVG.fo
 - Copyright (c) 2016, HerongYang.com, All Rights Reserved.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:simple-page-master master-name="page" 
   margin="0.1in" page-height="4in" page-width="3in">
   <fo:region-body region-name="body" background-color="#eeffff"/>
 <fo:page-sequence master-reference="page">
  <fo:flow flow-name="body">
   <fo:block border-width="1px" border-style="solid">
    <fo:block-container width="1in" border-width="1px"
     <fo:block>1 inch</fo:block>
    <fo:block-container width="72px" border-width="1px" 
     <fo:block>72 px</fo:block>
    <fo:block-container width="120px" border-width="1px" 
     <fo:block>120 px</fo:block>
    <fo:block border-width="1px" border-style="solid">
     Embedded SVG diagram:
<fo:instream-foreign-object width="1.5in" height="1.5in"
 content-width="scale-to-fit" content-height="scale-to-fit"
 <svg:svg width="200" height="200"
  viewBox="0 0 20 20">
  <svg:g style="fill:red; stroke:#000000">
   <svg:rect x="0" y="0" width="15" height="15"/>
   <svg:rect x="5" y="5" width="15" height="15"/>

If you process this example XSL-FO document with Apache FOP, you should see a diagram of two red boxes displayed on the page:

"instream-foreign-object" for a SVG Diagram

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


 PDF Printing Version