Re: [xsl] Fitting content to a box in FO

Subject: Re: [xsl] Fitting content to a box in FO
From: "Kevin Brown" <kevin@xxxxxxxxxxx>
Date: Wed, 13 Nov 2013 22:56:30 -0800
Tony gave some good answers. Possibly I get bonus points for doing this many
times already.

If you are using RenderX (I do not speak for other products), run the
document setting a large width and height. As long as you have fixed widths
and heights ... and in your case it would be height only. Format this to the
intermediate format and take a look.

In the XEP intermediate format, you can then easily get the actually height
of the content and scale the content appropriately (proportionally) to fit
within the actual fixed page dimensions.

RenderX intermediate format take both translate and transform tags to move
and even rotate/scale/skew information in any way.

http://www.renderx.com/cooltools.html

See document magnifier example.

You would simply inject one tag in the XEP intermediate format at the page
start to scale the content slightly so it fits the exact page dimensions.


Kevin Brown
RenderX





-----Original Message-----
From: xsl-list-digest-help@xxxxxxxxxxxxxxxxxxxxxx
[mailto:xsl-list-digest-help@xxxxxxxxxxxxxxxxxxxxxx]
Sent: Wednesday, November 13, 2013 10:10 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: xsl-list Digest 14 Nov 2013 06:10:00 -0000 Issue 3247

xsl-list Digest 14 Nov 2013 06:10:00 -0000 Issue 3247

Topics (messages 65037 through 65042):

Fitting content to a box in FO
	65037 by: Nic Gibson
	65042 by: Tony Graham

xsl:include
	65038 by: Nic Gibson
	65039 by: Nic Gibson
	65040 by: Tony Graham
	65041 by: Nic Gibson

Administrivia:

To subscribe to the digest, e-mail:
	<xsl-list-digest-subscribe@xxxxxxxxxxxxxxxxxxxxxx>

To unsubscribe from the digest, e-mail:
	<xsl-list-digest-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>

To post to the list, e-mail:
	<xsl-list@xxxxxxxxxxxxxxxxxxxxxx>


----------------------------------------------------------------------
Date: Wed, 13 Nov 2013 10:27:10 +0100
To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: Nic Gibson <nicg@xxxxxxxxxxxx>
Subject: Fitting content to a box in FO
Message-Id: <6C73E6CD-D0E1-4C83-A218-6B82F9BCB82C@xxxxxxxxxxxx>

Morning,

I have a question. Is there a way to state in XSL-FO =93here is a block = of
text (and possibly images), scale it to this maximum size?=94 The =
background is that I=92m looking to add better printing to the code I = use
to generate slides for presentations. The slides are originally HTML = and
fill a single =93page=94 - the screen. I want to print those out 3 = or 4 to
a page. Given that I know the size of the page I can work out = exactly how
large the =91box=92 for each slide should be. However, I = want to make sure
that the slide doesn=92t overflow the box. I don=92t = really care that much
if content is shrunk to fit, I just want to make = sure it fits the box.

Is that possible in XSL?

cheers

nic
--
Corbas Consulting / @CorbasLtd
Digital Publishing Consultancy and Training http://www.corbas.co.uk, +44
(0)7718 906817/+44 (0)1273 930765=

------------------------------

Date: Wed, 13 Nov 2013 14:09:55 -0000 (GMT)
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Subject: Re: [xsl] Fitting content to a box in FO
Message-ID:
<65198.83.147.131.233.1384351795.squirrel@xxxxxxxxxxxxxxxxxxxxxxxxxxx>

On Wed, November 13, 2013 9:27 am, Nic Gibson wrote:
> I have a question. Is there a way to state in XSL-FO here is a block
> of text (and possibly images), scale it to this maximum size? The
> background is that Im looking to add better printing to the code I
> use to generate slides for presentations. The slides are originally
> HTML and fill a single page - the screen. I want to print those out
> 3 or 4 to a page. Given that I know the size of the page I can work
> out exactly how large the box for each slide should be. However, I
> want to make sure that the slide doesnt overflow the box. I dont
> really care that much if content is shrunk to fit, I just want to make
sure it fits the box.

The messy-but-one-pass solution that preserves the proportions of your
slides would be to generate each slide as SVG and include each as either
fo:instream-foreign-object or fo:external-graphic with @max-height [1] set.
For bonus points, you could use @allowed-width-scale [2] so that your
over-tall slides scale down to a consistent set of font sizes.

The two-pass--all-FO solution -- as I describe at [3] -- would be run it
once with unconstrained height and get the area tree to work out how to
scale the slides.  For bonus points, you could generate an initial FO file
that has every slide at a range of font sizes and image magnifications, get
the area tree, and work out which font size works best for each slide.

The bleeding-edge solution [4] is to use FOP and the FOPRunXSLTExt [5]
extension from the Print and Page Layout CG to iteratively adjust the
font-size, etc., and run the FO processor from within your XSLT transform
until you have the optimal settings, which you then include in the 'real'
FO output.  For bonus points of a different kind, you could port the
extension to Antenna House's or RenderX's Java interface and contribute that
back to the CG.

Regards,

Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C

[1] http://www.w3.org/TR/xsl11/#max-height
[2] http://www.w3.org/TR/xsl11/#allowed-width-scale
[3]
http://www.balisage.net/Proceedings/vol10/html/Graham01/BalisageVol10-Graham
01.html#d44854e105
[4] That sometimes feels like the flogging-a-dead-horse solution [5]
http://www.w3.org/community/ppl/wiki/FOPRunXSLTExt#Example_5_-_Copyfitting_b
y_adjusting_.27font-size.27
[6] http://www.w3.org/community/ppl/

------------------------------

Date: Wed, 13 Nov 2013 10:28:22 +0100
To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: Nic Gibson <nicg@xxxxxxxxxxxx>
Subject: xsl:include
Message-Id: <B7D8CD64-1B14-437E-B82F-74D2172C3C37@xxxxxxxxxxxx>

I=92ve just been asked a question that I=92m having trouble answering.=20=

The question was =93could you give me a scenario where xsl:include is a =
better choice than xsl:import?=94 I can=92t think of one right now. = Anyone
got a good example?

cheers

nic
--
Corbas Consulting / @CorbasLtd
Digital Publishing Consultancy and Training http://www.corbas.co.uk, +44
(0)7718 906817/+44 (0)1273 930765

------------------------------

Date: Wed, 13 Nov 2013 10:28:22 +0100
To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: Nic Gibson <nicg@xxxxxxxxxxxx>
Subject: xsl:include
Message-Id: <021F0D2B-12D7-4A5A-A4C7-DF6D67444B32@xxxxxxxxxxxx>

I=92ve just been asked a question that I=92m having trouble answering.=20=

The question was =93could you give me a scenario where xsl:include is a =
better choice than xsl:import?=94 I can=92t think of one right now. = Anyone
got a good example?

cheers

nic
--
Corbas Consulting / @CorbasLtd
Digital Publishing Consultancy and Training http://www.corbas.co.uk, +44
(0)7718 906817/+44 (0)1273 930765

------------------------------

Date: Wed, 13 Nov 2013 10:19:32 -0000 (GMT)
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Subject: Re: [xsl] xsl:include
Message-ID:
<62517.83.147.131.233.1384337972.squirrel@xxxxxxxxxxxxxxxxxxxxxxxxxxx>

On Wed, November 13, 2013 9:28 am, Nic Gibson wrote:
> Ive just been asked a question that Im having trouble answering.
> The question was could you give me a scenario where xsl:include is a
> better choice than xsl:import? I cant think of one right now. Anyone
> got a good example?

When you don't want import precedence doing its thing, e.g., when the other
module works around potential template rule conflicts by using @priority, if
you import the other module, then templates in the current module won't play
nicely with the finely graduated @priority values in the other module.

Regards,

Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C

------------------------------

Date: Wed, 13 Nov 2013 11:40:36 +0100
To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: Nic Gibson <nicg@xxxxxxxxxxxx>
Subject: Re: [xsl] xsl:include
Message-Id: <FCEC311E-9914-47A4-BCA1-E18D2AD20170@xxxxxxxxxxxx>

Ah, yes

Thanks Tony

cheers

nic

On 13 Nov 2013, at 11:19, Tony Graham <tgraham@xxxxxxxxxx> wrote:

> On Wed, November 13, 2013 9:28 am, Nic Gibson wrote:
>> I=92ve just been asked a question that I=92m having trouble =
answering.
>> The question was =93could you give me a scenario where xsl:include is
>> =
a
>> better choice than xsl:import?=94 I can=92t think of one right now. =
Anyone got
>> a good example?
>=20
> When you don't want import precedence doing its thing, e.g., when the
>other module works around potential template rule conflicts by using
>@priority, if you import the other module, then templates in the =
current
> module won't play nicely with the finely graduated @priority values in
> =
the
> other module.
>=20
> Regards,
>=20
>=20
> Tony Graham                                   tgraham@xxxxxxxxxx
> Consultant                                 http://www.mentea.net
> Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
> --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
>    XML, XSL-FO and XSLT consulting, training and programming
>       Chair, Print and Page Layout Community Group @ W3C
>=20
>=20
>=20
>=20

--
Corbas Consulting / @CorbasLtd
Digital Publishing Consultancy and Training http://www.corbas.co.uk, +44
(0)7718 906817/+44 (0)1273 930765

------------------------------

End of xsl-list Digest
***********************************

Current Thread