//strange behaviour when Phrase first element of Document 
/*
itext-2.0.2

in following program:

using constructor 1): output overprinted
using constructor 2): output ok, but see also remark1

1)document.add(new Phrase(0,"vp="+vp));
2)document.add(new Phrase("vp="+vp));
*/

import java.io.*;
import java.sql.*;
import java.util.logging.*;

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


public class brol1
{ 
 public static void main(String[] args)
 throws Exception        
 {              
  boolean use1=true;
  if(args.length>0) use1=false;
  
  Document.compress=false;
  Rectangle pageSize=PageSize.A4;
  float ptop=pageSize.top();
  float pbottom=pageSize.bottom();
  float pright=pageSize.right();
  float pleft=pageSize.left();
  float pwidth=pright-pleft;
  float pheigth=ptop-pbottom;
  
  Document document=new Document(pageSize);
  String pdfnm="/tmp/brol1.pdf";
  PdfWriter pw=PdfWriter.getInstance(document,new FileOutputStream(pdfnm));
  
  document.open();
  float vp=pw.getVerticalPosition(false);

  float dtop=document.top();
  float dbottom=document.bottom();
  float dright=document.right();
  float dleft=document.left();
  float dwidth=dright-dleft;
  float dheigth=dtop-dbottom;
 
  //if document begins with only chunks,NEWLINE not honoured
  // first newlines missing,first chunks overprinted 
  // see 
http://article.gmane.org/gmane.comp.java.lib.itext.general/9959/match=chunk+newline
  if(use1) document.add(new Phrase(0,"vp="+vp));
  else document.add(new Phrase("vp="+vp));
  document.add(Chunk.NEWLINE);
  vp=pw.getVerticalPosition(false);
  //remark1 vp has not diminished!!??  
  document.add(new Chunk("vp="+vp+" ptop="+ptop+" pbottom="+pbottom+" 
pheight="+pheigth));
  document.add(Chunk.NEWLINE);
  vp=pw.getVerticalPosition(false);
  document.add(new Chunk("vp="+vp+" pleft="+pleft+" pright="+pright+" 
pwidth="+pwidth));
  document.add(Chunk.NEWLINE);  
  vp=pw.getVerticalPosition(false);
  document.add(new Chunk("vp="+vp+" dtop="+dtop+" dbottom="+dbottom+" 
dheight="+dheigth));
  document.add(Chunk.NEWLINE);  
  vp=pw.getVerticalPosition(false);
  document.add(new Chunk("vp="+vp+" dleft="+dleft+" dright="+dright+" 
dwidth="+dwidth));
  document.add(Chunk.NEWLINE);  
  document.close();
 }
}





_______________________________________________________________ 
Hot new product - Spider Networks introduces stunning online ePortfolio 
solution for students and teachers


http://www.spider-networks.net/solutions/eportfolio.html

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to