Bug 5001 - content-width and content-height ignored?
Summary: content-width and content-height ignored?
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: svg (show other bugs)
Version: all
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
: 2867 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-11-21 07:11 UTC by Jamie Lokier
Modified: 2012-04-01 06:34 UTC (History)
1 user (show)



Attachments
This patch makes content-width work to some extent (29.54 KB, patch)
2001-11-28 07:58 UTC, Jamie Lokier
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jamie Lokier 2001-11-21 07:11:02 UTC
I am trying to scale an SVG image, by using external-graphic with
the content-width and content-height attributes set.

Unfortunately whether I use "scale-to-fit" (to fit the width/height attributes),
or an explicit length, the graphic itself is not scaled.

I was not 100% sure that content-width and content-height should scale
the image, so I looked at the "XHTML to XSL formatting objects" example
XSLT file at http://www.antennahouse.com/axf11sampleEN.htm.

From there it looks like I'm generating the right XSL, and FOP is
not scaling the images as it should.

I have seen the example of a scaled image in the FOP documentation.
It uses an instream-foreign-object SVG, which references the external
SVG using "svg:image" and explicitly set width and height.

This does rescale the image, but unfortunately there is no way to have
the image size determined from the layout context.  For example, XSL
sizes such as "80%" to show an image with 80% of the width of the
current reference port do not work.

I am stuck working around this problem by using explicit sizes, and the
instream-foreign-object method for rescaling the image.

It would be nice if content-width and content-height were honoured.

cheers,
-- Jamie
Comment 1 Corinna 2001-11-22 06:09:01 UTC
Yes, these properties are ignored, see bug 3279.

To scale an image using external-graphic, put it into a table-cell of 
appropriate width. The height will then be scaled automatically.
Comment 2 Jamie Lokier 2001-11-28 07:54:15 UTC
Unfortunately I didn't have much luck with that.
The image was scaled but positioned wrongly, off the bottom of its
area instead of in the area.

I have tried to fix content-width and content-height and I've had some
luck.  ("scale-to-fit" now works).  However now I don't have the image
at the correct horizontal position, and I don't really understand the
flow of position data well enough.

content-width="scale-to-fit" width="80%" doesn't work (it produces a bad PDF
containing "NaN"), which of course is really what I want to do.
Comment 3 Jamie Lokier 2001-11-28 07:58:14 UTC
Created attachment 846 [details]
This patch makes content-width work to some extent
Comment 4 Jamie Lokier 2001-11-28 08:08:28 UTC
The above patch makes content-width (and height) accept "scale-to-fit", and does
scale an SVG image if they are used.  Absolute sizes also work.  Percentage
sizes in content-width/height should work (they are percentage of the image
intrinsic size), but I haven't tried them.

I have only tested instream-foreign-object containing an SVG.
It's entirely possible that external-graphic doesn't scale properly.

Specifying only one dimension to hasn't been properly coded (for calculating
the surrounding area size while preserving the image aspect ratio), and I've no
particular intention of doing that.

Specifying "width='80%' content-width='scale-to-fit'" doesn't work.  It
generates a bad PDF containing "NaN".  I don't understand how widths
are propagated through the area hierarchy so I won't be fixing this.

The image, though scaled nicely (on a PDF), is rendered at the wrong position.
There's a hack (x -= width/2) to move it which does help, but that's still
wrong.  I have no idea how to get the right position.

(It's taken me 3 weeks to understand Fop well enough to get this patch going,
which is too long for me so I'm giving up).

Hope the patch helps.
Comment 5 Oleg Tkachenko 2002-11-13 18:51:45 UTC
*** Bug 2867 has been marked as a duplicate of this bug. ***
Comment 6 Andreas Zielke 2004-11-05 07:06:02 UTC
We had the same problem. Using width instead of content-width seems to fix the
problem...
Comment 7 Andreas L. Delmelle 2007-02-18 02:44:46 UTC
Bugzilla cleanup:
Should be fixed in FOP 0.93/Trunk, where there is fully compliant support for the respective properties 
height, width, content-height and content-width on any fo:external-graphic or fo:instream-foreign-
object.
Comment 8 Glenn Adams 2012-04-01 06:34:21 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed