>> You have PdfWriter.getVerticalPosition()
>
> Thank you very much, this is what I need.

I have some problem with getVerticalPosition, because its value don't match
the correct one:
For example, I have a value of 806, I insert a new line with a pass of 20
pixel, and I have still 806!
I insert another new line with a pass of 20 pixel, and I have 786 (the
correct one are, after the first of 806, 786 and 760!).

N.B. I must insert new line ("\n") with a special Phrase, after previous
Phrase is completed, because I don't know the dimension of Phrase (and then
how much space I need between two lines) before the last Chunk is inserted.
This is the class for my test, and the output that result:

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

import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;

class testVerticalPosition
 {
  static Document document;
  static PdfWriter writer;

  public static void aggiungeFrase(int i) throws DocumentException
   {
    System.out.print("(int)writer.getVerticalPosition(false)=");
    System.out.println((int)writer.getVerticalPosition(false));
    System.out.print("Pixel from old line to new=");
    System.out.println(i);
    Phrase aCapo=new Phrase((float) (i));//new line with a pass of i pixel
    Chunk chunk=new Chunk(System.getProperty("line.separator"));//in
windows, "\n"
    aCapo.add(chunk);//add "\n" to Phrase
    document.add(aCapo);//add new line to Document
    document.add(new Phrase("Questa � una prova"));//add Phrase that go to a
new line, without "\n"
   }
  public static void main(String[] args)
   {
    try
     {
      document=new Document(PageSize.A4,36,36,36,36);
      writer=PdfWriter.getInstance(document,new
FileOutputStream("VerticalPosition.pdf"));
      document.open();
      for (int i=20;i<200;i=i+(int)(20*java.lang.Math.random()))
       {aggiungeFrase(i);}
     }
    catch (DocumentException de)
     {System.err.println(de.getMessage());}
    catch (IOException ioe)
     {System.err.println(ioe.getMessage());}
    document.close();
   }
 }

This is the output:

(int)writer.getVerticalPosition(false)=806

Pixel from old line to new=20

(int)writer.getVerticalPosition(false)=806

Pixel from old line to new=26

(int)writer.getVerticalPosition(false)=786

Pixel from old line to new=37

(int)writer.getVerticalPosition(false)=760

Pixel from old line to new=40

(int)writer.getVerticalPosition(false)=723

Pixel from old line to new=56

(int)writer.getVerticalPosition(false)=683

Pixel from old line to new=66

(int)writer.getVerticalPosition(false)=627

Pixel from old line to new=75

(int)writer.getVerticalPosition(false)=561

Pixel from old line to new=84

(int)writer.getVerticalPosition(false)=486

Pixel from old line to new=92

(int)writer.getVerticalPosition(false)=402

Pixel from old line to new=98

(int)writer.getVerticalPosition(false)=310

Pixel from old line to new=110

(int)writer.getVerticalPosition(false)=212

Pixel from old line to new=112

(int)writer.getVerticalPosition(false)=806

Pixel from old line to new=113

(int)writer.getVerticalPosition(false)=694

Pixel from old line to new=116

(int)writer.getVerticalPosition(false)=581

Pixel from old line to new=131

(int)writer.getVerticalPosition(false)=465

Pixel from old line to new=135

(int)writer.getVerticalPosition(false)=334

Pixel from old line to new=143

(int)writer.getVerticalPosition(false)=199

Pixel from old line to new=149

(int)writer.getVerticalPosition(false)=806

Pixel from old line to new=152

(int)writer.getVerticalPosition(false)=657

Pixel from old line to new=152

(int)writer.getVerticalPosition(false)=505

Pixel from old line to new=152

(int)writer.getVerticalPosition(false)=353

Pixel from old line to new=153

(int)writer.getVerticalPosition(false)=201

Pixel from old line to new=165

(int)writer.getVerticalPosition(false)=806

Pixel from old line to new=179

(int)writer.getVerticalPosition(false)=641

Pixel from old line to new=183

(int)writer.getVerticalPosition(false)=462

Pixel from old line to new=193

(int)writer.getVerticalPosition(false)=279

Pixel from old line to new=196






-------------------------------------------------------
This SF.net email is sponsored by Demarc:
A global provider of Threat Management Solutions.
Download our HomeAdmin security software for free today!
http://www.demarc.com/Info/Sentarus/hamr30
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to