Try this:

            java.awt.Image image25 = null;
            Barcode39 code39 = new Barcode39();
            code39.setCode("8004106861");
            image25 = code39.createAwtImage(Color.black, Color.white);

            java.awt.image.BufferedImage bi = new
java.awt.image.BufferedImage(image25.getHeight(null),image25.getWidth(nu
ll),java.awt.image.BufferedImage.TYPE_INT_RGB);
            java.awt.Graphics  g =  bi.getGraphics();
            java.awt.Graphics2D gg = (java.awt.Graphics2D)g;
            gg.translate(image25.getHeight(null), 0);
            gg.rotate(Math.toRadians(90));
            gg.drawImage(image25, 0, 0, null); 

The rotated barcode is available in bi.

Best Regards,
Paulo Soares

> -----Original Message-----
> From: john strecker [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 14, 2004 3:54 PM
> To: Paulo Soares
> Subject: RE: [iText-questions] rotating a generated barcode
> 
> Do you have any examples? I tried a few things and am getting totally
> lost.
> 
>               java.awt.Image image25 = null;
>             Barcode39 code39 = new Barcode39();
>             code39.setCode("8004106861");
>             image25 = code39.createAwtImage(Color.black, Color.white);
> 
>             AffineTransform tx = new AffineTransform();
>             double radians = Math.toRadians(90);
>             double xcentre = (image25.getWidth(null) / 2.0);
>             double ycentre = (image25.getHeight(null) / 2.0);
>             tx.rotate(radians, xcentre, ycentre);
>             tx.translate(0, image25.getHeight(null));
> 
>             Graphics  g =  new BufferedImage(2,
> 2,BufferedImage.TYPE_INT_RGB).getGraphics();
>             Graphics2D gg = (Graphics2D)g;
>             boolean bs = gg.drawImage(image25, tx, null);
>            
> -john
> 
> -----Original Message-----
> From: Paulo Soares [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 14, 2004 10:03 AM
> To: john strecker
> Subject: RE: [iText-questions] rotating a generated barcode
> 
> Create a BufferedImage, apply the transformation and place the image
> inside.
> 
> Best Regard,
> Paulo Soares
> 
> > -----Original Message-----
> > From: john strecker [mailto:[EMAIL PROTECTED] 
> > Sent: Friday, May 14, 2004 2:05 PM
> > To: Paulo Soares
> > Subject: RE: [iText-questions] rotating a generated barcode
> > 
> > Paul;
> >   
> > I am trying to generate/rotate a barcode for a Jasper report, 
> > so I need
> > a awt.Image. Additionally, I am trying to do this outside of a PDF
> > document so I don't need this attached to a PDF document. I 
> > just want to
> > generate it via IText, and rotate it, and save it as an 
> > independent AWT
> > object. All the examples with rotation I have seen use
> > createTemplateWithBarcode as follows:
> > 
> >     // create a barcode
> >      Barcode128 code128 = new Barcode128();
> >      code128.setCode("TEST123");
> > 
> >      // create a PdfTemaplate of the barcode
> >      PdfTemplate barCodeTemplate128 = 
> > code128.createTemplateWithBarcode(
> > cb, null, null );
> > // then rotate.
> > 
> > Has anyone done this independent of a PDF doc? Unless I am missing
> > something, the only way is to grab the Graphics object, which barfs.
> > 
> > -john
> > 
> > 
> > 
> > -----Original Message-----
> > From: Paulo Soares [mailto:[EMAIL PROTECTED] 
> > Sent: Thursday, May 13, 2004 6:21 AM
> > To: john strecker; [EMAIL PROTECTED]
> > Subject: RE: [iText-questions] rotating a generated barcode
> > 
> > Get the barcode as a com.lowagie.text.Image and rotate it.
> > 
> > Best Regards,
> > Paulo Soares 
> > 
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] 
> > > [mailto:[EMAIL PROTECTED] On 
> > > Behalf Of john strecker
> > > Sent: Wednesday, May 12, 2004 8:16 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: [iText-questions] rotating a generated barcode
> > > 
> > > Hello all;
> > >    I am trying to rotate a generated barcode from Itext for 
> > veritical 
> > > representation. Since there are not methods within the 
> > > barcode classes to do 
> > > this, I used the AWT classes vai the Image Object. However, 
> > > when I try to get 
> > > the graphics object I get the following error: Any 
> > > suggestions would be helpful.
> > > 
> > > Thanks
> > > John Strecker
> > > 
> > > 
> > > java.lang.IllegalAccessError: getGraphics() only valid for 
> > > images created with 
> > > createImage(w, h)
> > >   at sun.awt.windows.WImage.getGraphics(WImage.java:29)
> > > 
> > > 
> > > Here is my code snippet:
> > > 
> > >             Barcode39 code39 = new Barcode39();
> > >             code39.setCode("8004106861");
> > >             code39.setBarHeight(10);
> > >             Image image25 = 
> > > code39.createAwtImage(Color.black, Color.white);
> > > 
> > >             Graphics g = image25.getGraphics();
> > >             Graphics2D g2d = (Graphics2D) g;
> > >             AffineTransform tx = new AffineTransform();
> > >             double radians = Math.toRadians(90);
> > >             double xcentre = (image25.getWidth(null) / 2.0);
> > >             double ycentre = (image25.getHeight(null) / 2.0);
> > > 
> > >             tx.rotate(radians, xcentre, ycentre);
> > >             tx.translate(0, image25.getHeight(null));
> > >             g2d.drawImage(image25, tx, null);
> > > 
> > > 
> > > 
> > > 
> > > 
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by: SourceForge.net Broadband
> > > Sign-up now for SourceForge Broadband and get the fastest
> > > 6.0/768 connection for only $19.95/mo for the first 3 months!
> > > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
> > > _______________________________________________
> > > iText-questions mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/itext-questions
> > > 
> > > 
> > 
> > 
> > 
> 
> 
> 


-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id%62&alloc_ida84&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to