In order to learn the page geometry I built a trace into the PDFRenderer.
Then I found that SVG can be written easily at the trace points. An analysis
of the results follows.
____________________________________________________________________________
____________

Coordinates (o) received by the renderer: PDF with origin left/bottom

PDF
        Rectangle
        |||
        |||
        ||+-------
        |o--------
        +---------

        Line
        +-------
        o---------
        +---------

Coordinates used by SVG with origin left/top

        Rectangle
        o---------
        |+--------
        ||+-------
        |||
        |||

        Line
        o-------
        |---------
        +---------

_________________________________________________________________

Text Block

o There is a hidden overpainting priority: last one in time sequence wins

   The blue background rectangle

        <desc>FilledRect</desc>
        <rect x="70" y="115" width="453" height="-22" fill="rgb(0.0,0.0,255.0)"/>

        o FOP sends a negative height with corresponding reference coordinates: not
suppported by SVG

   Borders

        <desc>FilledRect</desc>
        <rect x="70" y="113" width="453" height="2" fill="rgb(255.0,0.0,0.0)"/>
        <desc>FilledRect</desc>
-->     <rect x="68" y="113" width="2" height="26" fill="rgb(255.0,0.0,0.0)"/>
        <desc>FilledRect</desc>
        <rect x="524" y="113" width="2" height="26" fill="rgb(255.0,0.0,0.0)"/>
        <desc>FilledRect</desc>
        <rect x="70" y="138" width="453" height="2" fill="rgb(255.0,0.0,0.0)"/>

        o Painted by 4 rectangles
        o Left border is shifted out into the left margin -->

   o Shipping borders as filled rectangles
        - prevents correct SVG positioning
        - dotted, dashed borders (anyway no properties available at present)

   Text

        <text x="70" y="131" font-size="18" font-family="sans-serif"
fill="rgb(255.0,255.0,0.0)">linked_to</text>
        <text x="147" y="131" font-size="18" font-family="sans-serif"
fill="rgb(255.0,255.0,0.0)">text2</text>
        <text x="191" y="131" font-size="18" font-family="sans-serif"
fill="rgb(255.0,255.0,255.0)">inline</text>
        <text x="238" y="131" font-size="18" font-family="sans-serif"
fill="rgb(255.0,255.0,0.0)">text2</text>
____________________________________________________________________________
____________

An Image

        <desc>renderImage URL
file:C:/HU/alt/Fop-0.20.1/docs/graphics/fop.jpg</desc>
        <rect x="70" y="156" width="100" height="60" />

        o Reference coordinates top/left
        o How big is an image given pixels/lines and rows without resolution? The
formatter has to know the extent of the image and no more.
        o The renderer has to handle various image formats and cache images if
needed at all.
        o As a courtesy the formatter can determine image formats and some image
properties as a common task, e.g.
                - pixels/lines and rows to allow a proportional scaling
                - color model
                - compression
        o Java 1.4's Advanced Imaging and Image I/O will allow a comfortable
programming
        o If the basics of image and PDF are known, image processing is a file
copy.
____________________________________________________________________________
____________

The Internal Link

   First comes the text

        <text x="70" y="242" font-size="12" font-family="sans-serif"
fill="rgb(0.0,0.0,0.0)">before_link</text>
        <text x="132" y="242" font-size="12" font-family="sans-serif"
fill="rgb(0.0,0.0,0.0)">internal_link</text>
        <text x="200" y="242" font-size="12" font-family="sans-serif"
fill="rgb(0.0,0.0,0.0)">after_link</text>


   and much later the link out of context
        <rect x="129" y="229" width="64" height="12" />

        o This is PDF principle of operation: OK, if device/format independence is
no goal of FOP
____________________________________________________________________________
____________

Foreign Object: SVG

        <rect fill="none" stroke-width="1" stroke="black" x="70" y="262"
width="250" height="50" />

        o At present Foreign Object = SVG.
        o The renderer can have it transcoded by Batik into a JPEG: about a dozen
statements.
        o Transcoder parameters: customization by compiling a Java class?
        o Postprocessing like an image.
        o The formatter has to know the extent of the object and no more.
____________________________________________________________________________
____________

o PDF rendering happens at about 6 trace points. PDFRenderer has lots of
unused code.

o A precise page geometry has to be calculated by the formatter: spaces,
(collapsing) borders, padding.

o Know the features of PDF and Java: correct graphic object (line,
rectangle, PDF path and stroke), caching, ressource management.

A formatter formats and a renderer renders. A strict separation is desirable
(keyword: device independence)- very few mutual imports. The formatter needs
only area dimensions and has to pass data to the renderer instead of
controlling and pushing it. xsl:fo input has to be setup, so that the
formatter just has to process text. No digging into other object types -
though they might have to be defined.

Ideally the renderer pulls the data in the sequence which it likes, so that
it does not have to save and manage data intermediately in memory.
Processing presentation objects is the job of the renderer. FOP is just
sequential batch processing in a few steps: why handlers, user agents,
windowing code?


Hansuli Anderegg

Attachment: rend01.pdf
Description: Adobe PDF document

<?xml version="1.0" encoding="utf-8"?>

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"; xmlns:svg="http://www.w3.org/2000/svg";>

  <fo:layout-master-set>
    <fo:simple-page-master master-name="simple"
                  page-height="29.7cm" 
                  page-width="21cm"
                  margin-top="1cm" 
                  margin-bottom="2cm" 
                  margin-left="2.5cm" 
                  margin-right="2.5cm">
      <fo:region-body margin-top="3cm"/>
      <fo:region-before extent="3cm"/>
      <fo:region-after extent="1.5cm"/>
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-name="simple">
    <fo:flow flow-name="xsl-region-body">

      <fo:block font-size="18pt"
      		border="solid" border-width="2pt"
      		border-color="red" border-style="solid"
      		id="block1"	
            font-family="sans-serif"
            line-height="24pt"
            space-after.optimum="15pt"
            background-color="blue"
            color="yellow"
            text-align="start">
         linked_to text2
         <fo:inline
			background-color="black"
            color="white">
   		 inline
   		 </fo:inline>
		 text2	
      </fo:block>

<fo:block space-after.optimum="15pt">
<fo:external-graphic src="C:\HU\alt\Fop-0.20.1\docs\graphics\fop.jpg"/>
</fo:block>

<fo:block space-after.optimum="15pt">
before_link
<fo:basic-link internal-destination="block1" border-width="1pt">internal_link</fo:basic-link>
after_link
</fo:block>

<!--
<fo:block space-after.optimum="15pt">
before_link
<fo:basic-link external-destination="dummy.xxx" border-width="1pt" border-color="black" >external_link</fo:basic-link>
after_link
</fo:block>
-->

<fo:block space-after.optimum="15pt" border-width="1pt" border-color="black">
<fo:instream-foreign-object width="250pt" height="50pt" border-width="1pt" border-color="black" >
<svg:svg width="250" height="50">
  <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"/>
  </svg:g>
    <svg:text x="10" y="30">SVG placed in a block</svg:text>
</svg:svg>
</fo:instream-foreign-object>
</fo:block>
    </fo:flow> <!-- closes the flow element-->
  </fo:page-sequence> <!-- closes the page-sequence -->
</fo:root>

<<attachment: rend01_svg.jpg>>

Attachment: rend01.svg
Description: image/svg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to