Quantcast

how to use ColumnText

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to use ColumnText

Neha Yadav
hello,
       we used ColumnText as suggested by you we are able to get the vertical position when we use it for a single page with no columns. But as we use ColumnText further for a page having two or more column we are not getting the vertical position. kindly tell us how to do it  for a page containing two or more column.
 Like in this code I am getting Yline-
code 1-

PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
BufferedReader reader =
new BufferedReader(new FileReader("caesar.txt"));
String line;
Create ColumnText object

while ((line = reader.readLine()) != null) {
ct.addText(new Phrase(line + "\n"));
}
reader.close();

ct.setSimpleColumn(36, 36,
PageSize.A4.width() - 36, PageSize.A4.height() - 36
18, Element.ALIGN_JUSTIFIED);
int status = ColumnText.START_COLUMN;
while (ColumnText.hasMoreText(status)) {
status = ct.go();
ct.setYLine(PageSize.A4.height() - 36);
document.newPage();
}

But now I have to add more than 1 column like-
code-2
float[] left = { 36, (PageSize.A4.width() / 2) + 18 };
float[] right = { (PageSize.A4.width() / 2) - 18,PageSize.A4.width() - 36 };
int status = ColumnText.NO_MORE_COLUMN;
int column = 0;

while (ColumnText.hasMoreText(status)) {
ct.setSimpleColumn(left[column], 36,
right[column], PageSize.A4.height() - 36);
status = ct.go();

}

in the code-2 how can I split the text in second column?
 
Thank You.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use ColumnText

Paulo Soares-3
Did you look at the book and at the examples? ColumnText is a single column but you can continue the column someplace else, in the same page or in the next page. Plenty of examples are available.

Paulo

-----Original Message-----
From: Neha Yadav [mailto:[hidden email]]
Sent: Monday, March 15, 2010 11:10 AM
To: [hidden email]
Subject: [iText-questions] how to use ColumnText


hello,
       we used ColumnText as suggested by you we are able to get the
vertical position when we use it for a single page with no columns. But as
we use ColumnText further for a page having two or more column we are not
getting the vertical position. kindly tell us how to do it  for a page
containing two or more column.
 Like in this code I am getting Yline-
code 1-

PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
BufferedReader reader =
new BufferedReader(new FileReader("caesar.txt"));
String line;
Create ColumnText object

while ((line = reader.readLine()) != null) {
ct.addText(new Phrase(line + "\n"));
}
reader.close();

ct.setSimpleColumn(36, 36,
PageSize.A4.width() - 36, PageSize.A4.height() - 36
18, Element.ALIGN_JUSTIFIED);
int status = ColumnText.START_COLUMN;
while (ColumnText.hasMoreText(status)) {
status = ct.go();
ct.setYLine(PageSize.A4.height() - 36);
document.newPage();
}

But now I have to add more than 1 column like-
code-2
float[] left = { 36, (PageSize.A4.width() / 2) + 18 };
float[] right = { (PageSize.A4.width() / 2) - 18,PageSize.A4.width() - 36 };
int status = ColumnText.NO_MORE_COLUMN;
int column = 0;

while (ColumnText.hasMoreText(status)) {
ct.setSimpleColumn(left[column], 36,
right[column], PageSize.A4.height() - 36);
status = ct.go();

}

in the code-2 how can I split the text in second column?
 
Thank You.


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
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
[hidden email]
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use ColumnText

Neha Yadav

hi
  I  referred the examples from the itext book for ColumnText would you please tell me which perticular chapter or example should I refer again.

Paulo Soares-3 wrote
Did you look at the book and at the examples? ColumnText is a single column but you can continue the column someplace else, in the same page or in the next page. Plenty of examples are available.

Paulo

-----Original Message-----
From: Neha Yadav [mailto:neha.yadav@eworks.in]
Sent: Monday, March 15, 2010 11:10 AM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] how to use ColumnText


hello,
       we used ColumnText as suggested by you we are able to get the
vertical position when we use it for a single page with no columns. But as
we use ColumnText further for a page having two or more column we are not
getting the vertical position. kindly tell us how to do it  for a page
containing two or more column.
 Like in this code I am getting Yline-
code 1-

PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
BufferedReader reader =
new BufferedReader(new FileReader("caesar.txt"));
String line;
Create ColumnText object

while ((line = reader.readLine()) != null) {
ct.addText(new Phrase(line + "\n"));
}
reader.close();

ct.setSimpleColumn(36, 36,
PageSize.A4.width() - 36, PageSize.A4.height() - 36
18, Element.ALIGN_JUSTIFIED);
int status = ColumnText.START_COLUMN;
while (ColumnText.hasMoreText(status)) {
status = ct.go();
ct.setYLine(PageSize.A4.height() - 36);
document.newPage();
}

But now I have to add more than 1 column like-
code-2
float[] left = { 36, (PageSize.A4.width() / 2) + 18 };
float[] right = { (PageSize.A4.width() / 2) - 18,PageSize.A4.width() - 36 };
int status = ColumnText.NO_MORE_COLUMN;
int column = 0;

while (ColumnText.hasMoreText(status)) {
ct.setSimpleColumn(left[column], 36,
right[column], PageSize.A4.height() - 36);
status = ct.go();

}

in the code-2 how can I split the text in second column?
 
Thank You.


Aviso Legal:

Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.



Disclaimer:

This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.




------------------------------------------------------------------------------
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
iText-questions@lists.sourceforge.net
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use ColumnText

info-2
Neha Yadav wrote:
>
> hi
>   I  referred the examples from the itext book for ColumnText would you
> please tell me which perticular chapter or example should I refer again.

You should read chapter 7 in the first edition,
or chapter 3 in the second edition.

Which examples? All of them.

In your code-2, you define left and right borders for
two columns. I thought you needed to do this for 4 sectors
on the page, so I wonder why you aren't defining 4 rectangles
instead of two pairs of X and Y values.

Now you have the top and the bottom hardcoded in the
setSimpleColumn() method.

Moreover: you define two pairs of X and Y values (a left
and a right border), but you only use one X and one Y.
I don't see you changing column to 1 anywhere.
So you aren't using "(PageSize.A4.width() / 2) + 18"
and "PageSize.A4.width() - 36" anywhere.

It's hard to imagine why it surprises you that the second
column doesn't show up on the page.

I have the impression that you didn't read the chapters
mentioned above, because it looks like you don't know
what the variable "column" is meant for.

Please read the chapters that were advised and come back
later if you know more.

------------------------------------------------------------------------------
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
[hidden email]
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/
Loading...