RE: [xep-support] Re: Image scaling

From: Kevin Brown <>
Date: Wed Dec 10 2008 - 08:52:49 PST



This is possible to accomplish without "two passes" but does require special
processing of the intermediate format file
fication ). This is similar in nature to the Transpromo application we
created for a customer. Take a look at this white paper from the RenderX
web site (


The problem here is to inject a variable size image into a document. Think
of your monthly statement from a bank. The last page frequently has
available white space below the last line items and summary. The image to
inject is based some parameters from your account (like balance) and of
course on available white space. The solution lies in the fact that RenderX
supports a hidden extension element <rx:pinpoint>. This element has a
"value" attribute and when dropped in the FO source, it will be placed in
the RenderX Intermediate Format (xml) file. The Intermediate File can be
obtained from RenderX software for any application using the API or even
command line. You can then process this intermediate file to "find"
pinpoints. In the intermediate format, pinpoints carry the "value" attribute
as a marker for you as well as attributes about its position on the page (x,
y location) like this:


<xep:pinpoint x="56693" y="262888" value="promo,96;promo1.jpg"/>


So, in your application, one could measure the height of this table cell
using two <rx:pinpoints> and then using a little XSLT math find out the
height. Better, if you fill the table cell in question with a specific
color, then you could search the intermediate file and find and extract the
dimensions of the <xep:rectangle> that is that color and you will know the
exact size of the space. This would be like this but preceded by your color:


<xep:gray-color gray="1.0"/>
<xep:rectangle x-from="56693" y-from="56693" x-till="526693"


Then, without even reprocessing anything, you could modify the intermediate
format to add the SVG with the proper height and then send the intermediate
file to the RenderX backend. You would only need to convert XEP units to
your units but this is easy as XEP units are 0.001pt.


All of this could be done programmatically without human intervention and
the RenderX team uses such techniques all the time in custom situations for
inserting OMR marks, special barcoding, concatenation of huge mail packages,
custom layouts that span columns, etc.


In addition, there is another white paper that uses this same technique to
measure areas for PDF form fields and dynamically creates a fillable form by
calling iText software with the intermediate file "measurements" to stamp
the form fields. This paper is posted here:


Kevin Brown

Executive Vice President, Sales & Marketing

RenderX, Inc.

(650) 328-8000 Main

(650) 327-1000 Direct

(650) 328-8008 Fax

(925) 395-1772 Mobile

 <skype:kbrown01?call> skype:kbrown01








From: []
On Behalf Of Mark Cilia Vincenti
Sent: Wednesday, December 10, 2008 7:08 AM
Subject: Re: [xep-support] Re: Image scaling




A RenderX extension that takes a line of text, a font family, a font-size,
width of a block in pixels and outputs the number of lines this would fit on
would be nice :)


<xsl:variable name="numlines"><rx:number-of-lines font-family="MyriadPro"
font-size="12pt" width="210mm" text="This is a long line and I wonder how
many lines it will end up wrapping on. Perhaps two or three, who knows?"



<xsl:when test="$numlines = 1">.........</xsl:when>

<xsl:when test="$numlines = 2">.........</xsl:when>





... or even better <rx:number-of-lines> would allow nested blocks inside it
for when you have words that are bolded and others which aren't.

2008/12/10 Jim Mott <>



I don't have any special insight on this, but I was thinking before when I
read your first posting that the engine would not be able to know the height
on just one pass precisely because of the variable height of the text. It
seems to me you have to get feedback from the engine as an intermediary
stage and provide the height on a second pass.


Jim Mott


----- Original Message -----

From: Mark Cilia Vincenti <>


Sent: December 10, 2008 3:33 AM

Subject: Re: [xep-support] Re: Image scaling


Hi Alexei,


Thanks for your email.

Unfortunately it's the height I don't know, because if the text in the box
wraps, then it would increase the height. I tried cheating using
reference-orientation but it did not work.

2008/12/10 Alexei Gagarinov <>

Hi Mark,

<fo:block line-height="0pt">
       content-width="scale-to-fit" content-height="scale-to-fit"
       scaling="non-uniform" scaling-method="resample-any-method">


You should set the viewport's area using @width and @height attributes on
the fo:external-graphic element.

If @width and @height are omitted then they are treated as 'auto' and it
means that viewport's area equals to the intrinsic size of the graphic.

And what you do is scaling the intrinsic size of the image to the ... yeah,
to the same value.

So, in order to scale the graphics width to a table cell, you need the
<fo:external-graphic width="100%" content-width="scale-to-fit" src="...">

But you cannot scale the image's height to an arbitrary block (a table cell
in your example) using a percentage value because the height of this block
depends of its content.
So you should know the height of the surrounding box ahead and specify this
length as a value of @height on fo:external-graphic.

 Alexey Gagarinov

(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service



(*) To unsubscribe, send a message with words 'unsubscribe xep-support'
in the body of the message to from the address
you are subscribed from.
(*) By using the Service, you expressly agree to these Terms of Service
Received on Wed Dec 10 09:07:58 2008

This archive was generated by hypermail 2.1.8 : Wed Dec 10 2008 - 09:08:05 PST