Hi,

I was wondering why the following code doesn't print
an oval as it should. Can anyone help?

I 'm using itext 1.3.

Thanks in advance.

Best regards,

John

/*
 * $Id: Text.java
 */

import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Rectangle;
import com.lowagie.text.PageSize;
import com.lowagie.text.pdf.DefaultFontMapper;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfTemplate;
import com.lowagie.text.pdf.PdfWriter;

/**
 * A simple Graphics2D example.
 */
public class Test {

    /**
     * A simple Graphics2D example
     * @param args no arguments needed
     */
    public static void main(String[] args) {
        
        System.out.println("Using the
java.awt.Graphics2D-object");
        
        // step 1: creation of a document-object
        Document document = new Document(new
Rectangle(530, 370));
        
        try {
            
            // step 2: creation of the writer
            PdfWriter writer =
PdfWriter.getInstance(document, new
FileOutputStream("test.pdf"));
            
            // step 3: we open the document
            document.open();
            
            // step 4: we grab the ContentByte and do
some stuff with it
            
            // we create a fontMapper and read all the
fonts in the font directory
            DefaultFontMapper mapper = new
DefaultFontMapper();
            FontFactory.registerDirectories();
           
mapper.insertDirectory("c:\\windows\\fonts");
            // we create a template and a Graphics2D
object that corresponds with it
            int w = 500;
            int h = 350;
            PdfContentByte cb =
writer.getDirectContent();
            PdfTemplate tp = cb.createTemplate(w, h);
            Graphics g = tp.createGraphics(w, h,
mapper);
            tp.setWidth(w);
            tp.setHeight(h);
            //double ew = w/2;
            //double eh = h/2;
            g.setColor(Color.black);
            //g.drawOval(10,10,100,60);
                        g.drawOval(162,88,156,87);
            g.dispose();
            cb.addTemplate(tp, 50, 400);
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
            System.err.println(ioe.getMessage());
        }
        
        // step 5: we close the document
        document.close();
    }

}


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to