Quantcast

how to use Element.ALIGN_JUSTIFIED in one line in 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 Element.ALIGN_JUSTIFIED in one line in ColumnText?

forest
Hello guys,
        I want to write a program to make Author of index file  like this:
        AuthorA ..............................1 
        AuthorBBB.........................12
        The hard work is to calculate how many points should I add, I use Basefont's method GetWidthPoint to get the print width of author name.The result is float type, but number of points is integer type,so every line's final width is not exactly equal.So I want to use text alignment to achieve this,but it seems vain .I googled Justified text, which is text in which all the printed lines in a paragraph (except the final line) are made the same length by the adjustment of spacing between words.
         I use ColumnText addtext( new Phrase("AuthorA ..............................1" + "\n"),font)
         The result is that not all the lines exactly aligned to the right column.How can I make them exactly aligned?
         Thanks in advance.
Best regards
senlin

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use Element.ALIGN_JUSTIFIED in one line in ColumnText?

Bob Barnes
Senlin,

   There are a few different approaches you could try, but they all involve using DottedLineSeparator. One that works for me is as follows:

Chunk chunk=new Chunk("Some text",someFont);
Paragraph paragraph = new Paragraph(chunk);
paragraph.setAlignment(Element.ALIGN_LEFT);
paragraph.add(new Chunk(new DottedLineSeparator()));
chunk=new Chunk(aPageNumber, someFont);
paragraph.add(chunk);

   Since you didn't provide much code it's a bit difficult to offer a more concrete solution, but I'd say what you're currently doing is definitely NOT the way to go.

Bob


On Oct 27, 2010, at 9:38 PM, forest wrote:

Hello guys,
        I want to write a program to make Author of index file  like this:
        AuthorA ..............................1 
        AuthorBBB.........................12
        The hard work is to calculate how many points should I add, I use Basefont's method GetWidthPoint to get the print width of author name.The result is float type, but number of points is integer type,so every line's final width is not exactly equal.So I want to use text alignment to achieve this,but it seems vain .I googled Justified text, which is text in which all the printed lines in a paragraph (except the final line) are made the same length by the adjustment of spacing between words.
         I use ColumnText addtext( new Phrase("AuthorA ..............................1" + "\n"),font)
         The result is that not all the lines exactly aligned to the right column.How can I make them exactly aligned?
         Thanks in advance.
Best regards
senlin
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use Element.ALIGN_JUSTIFIED in one line in ColumnText?

forest
In reply to this post by forest
Dear Bob Barnes,
        Thank you very much,DottedLineSeparator is what I want ,just what DottedLineSeparator draw is not like '.' which looks like a tiny triangle.Maybe I can write my own DottedLineSeparator to make it more like circle.Thanks again.
 
best regards
senlin

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: how to use Element.ALIGN_JUSTIFIED in one line in ColumnText?

info-2
On 28/10/2010 9:23, forest wrote:
> Dear Bob Barnes,
> Thank you very much,DottedLineSeparator is what I want ,just what
> DottedLineSeparator draw is not like '.' which looks like a tiny
> triangle.Maybe I can write my own DottedLineSeparator to make it more
> like circle.Thanks again.

The DottedLineSeparator uses a dash pattern where the dots are "lines"
with zero length and a rounded line cap. It should be circles, but it's
up to the viewer to decide how to render such a dash pattern.

Your idea to write your own DottedLineSeparator is excellent. That's
what the DrawInterface and the VerticalPositionMark are for. This way
you can implement the dotted line according to your needs.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
iText-questions mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
Loading...