Hello

I use iText version 2.1.7

I want put text in position x= 12 millimeters and position y = 100 
millimeters
For this purpose I use this methods :

writer.getDirectContent().moveText(Utilities.millimetersToPoints(12),Utilities.millimetersToPoints(100));
writer.getDirectContent().showText("Hello world");


I printed document created in this way and text starts from position 
x=18 millimeters.
I can't figure out what I do wrong.


Bellow is my code:

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Rectangle;
import com.lowagie.text.Utilities;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;


public class PositionExample {

    /**
     * @param args
     */
    public static void main(String[] args) {
       
        Document document = new Document(new Rectangle(595, 841));
       
        try {
            PdfWriter writer = PdfWriter.getInstance(document,
                    new FileOutputStream("PositionExample.pdf"));
           
            document.open();
           
            writer.getDirectContent().beginText();
            
writer.getDirectContent().setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA,
 
BaseFont.CP1252, BaseFont.NOT_EMBEDDED),12);
            
writer.getDirectContent().moveText(Utilities.millimetersToPoints(12),Utilities.millimetersToPoints(100));
            writer.getDirectContent().showText("Hello world");
            writer.getDirectContent().endText();
           
           
            document.close();
           
       
        } catch (FileNotFoundException e) {
           
            e.printStackTrace();
        } catch (DocumentException e) {
           
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}



Thanks for help
Best Regards
Kamil


__________ Informacja programu ESET NOD32 Antivirus, wersja bazy sygnatur 
wirusow 4886 (20100222) __________

Wiadomosc zostala sprawdzona przez program ESET NOD32 Antivirus.

http://www.eset.pl lub http://www.eset.com 



----------------------------------------------------------------------
Szybkie i niedrogie... Tylko dla mezczyzn!
Sprawdz >>> http://link.interia.pl/f25a7


------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
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
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to