i'm sorry but in the Romeo and Juliet example you only use your variable 'act' 
in "onEvent" methods : onchapter, onendpage but NOT in your method main : this 
is 
the problem. I hava tested and retested and reretested i can't use a variable 
like 'act' initilazed in the main methods in other events methods.
This is what i need to do.
Let me show you a sample

public String test = "-";
public void buildpdf()
{
..
test = "j'initialise ma variable";
document.open();
..
}

public void ondocumentOpen()
{
System.out.println("test vaut "+test);

}

Output : test vaut -

I hope you've understood.

Farid.


---- Original Message ----
From:           bruno
Date:           Thu 8/11/05 11:46
To:             Farid KHEZZAR, 'itext-questions@lists.sourceforge.net'
Subject:        Re: iText : page events and global variables

Farid KHEZZAR wrote:

>hi bruno
>
>  
>
Hi,
please use the mailing list address if you have a question:
itext-questions@lists.sourceforge.net

>i'm using the iText library to generate pdf files,
>i have headers and footers which are built in the onEndPage method and to 
>build 
>them i need variables initialized in my main method which build the document 
>(from 
>a heavy sql query that i don't want to repeat)
>i thought it would be simple : declare a glabal variable, initalize it in my 
>main 
>method and then use it in the onEndPage method
>but my problem is that "onEvent" methods can't share variables with other 
>methods, 
>  
>
Why not? In my PdfPageEvent implementations, I look at all kinds of 
variables in order to compose a header, a watermark, whatever.

>so how can I do without repeating 2 times the same heavy query ??
>  
>
In your questions you make some assumptions that are wrong. I don't 
think you understand the concept of Events. Have you tried the examples 
in the tutorial? 
http://itextdocs.lowagie.com/tutorial/directcontent/pageevents/
Look at how I change the header with the 'act' in the Romeo and Juliet 
example.
br,
Bruno



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to