Bug 27971 - [PATCH] Bugs on the transformation of the linearGradient element for SVG to PDF
Summary: [PATCH] Bugs on the transformation of the linearGradient element for SVG to PDF
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: svg (show other bugs)
Version: trunk
Hardware: PC Windows XP
: P3 major
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-26 06:39 UTC by Gang Liu
Modified: 2012-04-01 06:27 UTC (History)
1 user (show)



Attachments
The converted PDF file from the given SVG file (1.93 KB, application/pdf)
2004-03-26 06:43 UTC, Gang Liu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gang Liu 2004-03-26 06:39:33 UTC
There's a bug found while converting an SVG file to PDF file with some 
functionalities of linearGradient and object translation, using the FOP 
version xml-fop_20040318232912.tar.gz

The source SVG file contains two rect shapes, one is located from the origin, 
another is translated for some distance. Both of them are employed with a same 
linearGradient, names "linearGradient1", which is defined based on the origin 
of the SVG coordinate. However, in the converted PDF file, the translated rect 
object just displays a single color (the second stop color of the 
linearGradient), while the un-translated rect object displays normally.
We found the root cause of this issue maybe the improper concatinating 
transformations implemented in the ApplyPaint() function of the class 
org.apache.fop.svg.PDFGraphics2D, omitting a necessary concatinating transform:
=============================
//MultipleGradientPaint.CycleMethodEnum cycenum = gp.getCycleMethod();
            //boolean cyclic = (cycenum == MultipleGradientPaint.REPEAT);
            AffineTransform transform = graphicsState.getTransform();
            transform.concatenate(gp.getTransform());
            transform.concatenate(getTransform()); ///Here the fixing
=============================

The sample of SVG file is attached as below:
===================================================================
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="800" height="600" viewBox="0 0 800 600"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<desc>Example lingrad01 - fill a rectangle using a
linear gradient paint server</desc>
<g>
<defs>
<linearGradient x1="10" gradientUnits="userSpaceOnUse" x2="300" y1="10" 
y2="300" id="linearGradient1" spreadMethod="pad">
        <stop style="stop-opacity:1; stop-color:blue;" offset="0%" />
        <stop style="stop-opacity:1; stop-color:green;" offset="100%" />
</linearGradient>
</defs>
<!-- The rectangle is filled using a linear gradient paint server -->
<rect x="10" y="10" width="290" style="fill:url(#linearGradient1); 
stroke:none;" height="290" />
<rect transform="translate(300,300)" x="10" y="10" width="290" style="fill:url
(#linearGradient1); stroke:none;" height="290" />
<rect x="0" y="0" height="600" width="800" style="stroke:red; fill:none"/>
</g>
</svg>
============================================================================
Comment 1 Gang Liu 2004-03-26 06:43:06 UTC
Created attachment 11003 [details]
The converted PDF file from the given SVG file
Comment 2 Chris Bowditch 2004-03-26 09:12:21 UTC
Thanks for finding this issue. Please could you submit your suggested change 
as a unified diff and attach (not copy and paste) it to this bug report. I 
would also be grateful if you could attach the SVG (rather than copy and paste 
into the text)

Thanks
Comment 3 Jeremias Maerki 2004-04-03 09:57:28 UTC
Looks good. Applied. But as Chris said, we'd be grateful if you sent a unified 
diff against CVS next time. Thank you!
Comment 4 Glenn Adams 2012-04-01 06:27:52 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed