So figured it out, and thought I would post this in case someone else needs
to know...
It was working, but the borders are a little weird on PDF. It seems like
the minimum y value is around 70. Any higher than that is off the page.
But the min x value is still 0. I know the given point is the bottom left
anchor of the text, but I checked the text height, and it was only 15
(measured via font metrics). Not really sure why the starting y value is so
large.
-Neel
On Tue, Jul 29, 2008 at 7:42 PM, Neel Parekh <[EMAIL PROTECTED]> wrote:
> So I'm just trying to start out using the Graphics2D version of iText, and
> for some reason, I'm not seeing anything showing up... the pdf is created,
> but it's blank. My code is below. Any help you could offer would be
> greatly appreciated.
>
> FYI... I'm using iText version 1.4.1, but I tried it with 2.1.3 with no
> success.
>
> Thanks.
> -Neel
>
> public static void main(String args[]) {
> try {
> FileOutputStream fos = new FileOutputStream("/tmp/print/test.pdf");
> doTest(fos);
> } catch (Exception e) {
> e.printStackTrace();
> }
> System.out.println("Done");
> }
>
>
> public static void doTest(OutputStream os) {
> try {
> Document d = new Document();
> PdfWriter writer = PdfWriter.getInstance(d, os);
> d.open();
> PdfContentByte cb = writer.getDirectContent();
> Graphics2D g2 = cb.createGraphics(300, 900);
> g2.setColor(Color.black);
> g2.drawString("Testing", 20, 20);
> g2.dispose();
>
> d.close();
>
> os.close();
> } catch (Exception e) {
> throw new RuntimeException(e);
> }
> }
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php