You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by useratnab <Ti...@gmx.net> on 2009/01/21 14:55:57 UTC

AffineTransform on 2nd page

Hello,

I'm trying to load a schematic xml and this works fine, until the point
where a second page with text output should be created. The Text is always
on different positions and sometimes turned around.

How can I specify a diffrebt transformation on a second PDF page:


private SchematicCanvas schem;

            FileOutputStream fos = new FileOutputStream(f);
            int width = 842;    // A4 in 72dpi
            int height = 595;
            
            pdf2D = new PDFDocumentGraphics2D( false, fos, width, height );
            Rectangle rb = schem.cont.getBounds();
   
            
            pdf2D.setGraphicContext(new GraphicContext());            
            
            double scale = (double)width / rb.width;
            double scale2 = (double)height / rb.height;
            double x0 = rb.x;
            double y1 = rb.y + rb.height;
            
            if (scale2 < scale) scale = scale2;
            scale *= 0.9;
            x0 -= (width / scale - rb.width) / 2.;
            y1 += (height / scale - rb.height) / 2.;
   
                     
            AffineTransform Tx = new AffineTransform( scale, 0, 0, scale,
                  -x0*scale* 300. / 72., y1*scale* 300. / 72.);
            
            pdf2D.setTransform(Tx);
            
            pdf2D.drawRect(rb.x, rb.y, rb.width, rb.height);            
                     
                        
            schem.cont.paint(pdf2D, null);
            
            
            pdf2D.nextPage();
            
                        
            pdf2D.setGraphicContext(new GraphicContext());
            pdf2D.setColor(Color.blue);
            
            AffineTransform old = pdf2D.getTransform();               
            
            AffineTransform Tx2 = new AffineTransform(new values);
            pdf2D.setTransform(Tx2);
            
            
            pdf2D.drawString("Hello World", 0, 0);
            
                        
            pdf2D.setTransform(old);

-- 
View this message in context: http://www.nabble.com/AffineTransform-on-2nd-page-tp21583607p21583607.html
Sent from the FOP - Users mailing list archive at Nabble.com.

Re: AffineTransform on 2nd page

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Sounds like a bug in PDFDocumentGraphics2D. Please note that not many
people will likely use this directly so it may not work as expected.
Help to fix these issues would be appreciated. I'm afraid I don't have
enough time to look into this at the moment.

On 21.01.2009 14:55:57 useratnab wrote:
> 
> Hello,
> 
> I'm trying to load a schematic xml and this works fine, until the point
> where a second page with text output should be created. The Text is always
> on different positions and sometimes turned around.
> 
> How can I specify a diffrebt transformation on a second PDF page:
> 
> 
> private SchematicCanvas schem;
> 
>             FileOutputStream fos = new FileOutputStream(f);
>             int width = 842;    // A4 in 72dpi
>             int height = 595;
>             
>             pdf2D = new PDFDocumentGraphics2D( false, fos, width, height );
>             Rectangle rb = schem.cont.getBounds();
>    
>             
>             pdf2D.setGraphicContext(new GraphicContext());            
>             
>             double scale = (double)width / rb.width;
>             double scale2 = (double)height / rb.height;
>             double x0 = rb.x;
>             double y1 = rb.y + rb.height;
>             
>             if (scale2 < scale) scale = scale2;
>             scale *= 0.9;
>             x0 -= (width / scale - rb.width) / 2.;
>             y1 += (height / scale - rb.height) / 2.;
>    
>                      
>             AffineTransform Tx = new AffineTransform( scale, 0, 0, scale,
>                   -x0*scale* 300. / 72., y1*scale* 300. / 72.);
>             
>             pdf2D.setTransform(Tx);
>             
>             pdf2D.drawRect(rb.x, rb.y, rb.width, rb.height);            
>                      
>                         
>             schem.cont.paint(pdf2D, null);
>             
>             
>             pdf2D.nextPage();
>             
>                         
>             pdf2D.setGraphicContext(new GraphicContext());
>             pdf2D.setColor(Color.blue);
>             
>             AffineTransform old = pdf2D.getTransform();               
>             
>             AffineTransform Tx2 = new AffineTransform(new values);
>             pdf2D.setTransform(Tx2);
>             
>             
>             pdf2D.drawString("Hello World", 0, 0);
>             
>                         
>             pdf2D.setTransform(old);
> 
> -- 
> View this message in context: http://www.nabble.com/AffineTransform-on-2nd-page-tp21583607p21583607.html
> Sent from the FOP - Users mailing list archive at Nabble.com.




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org