|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
DottedLineSeparator and paragraph alignmentHi,
When using the DottedLineSeparator I can get it to work if the Paragraph is aligned left. I have a columnText and a pdftable with one cell. The paragraph is added to the cell. If I have 3 chunks and the middle is a DottedLineSeparator then it will only work if the paragraph is aligned left. If I use center or right the bounds are not kept. The text does not stay in the columnText and the pdftable. I have used fixed width and height for the table. Any clues? |
|
|
Re: DottedLineSeparator and paragraph alignmentMathias Nilsson wrote:
> Hi, > > When using the DottedLineSeparator I can get it to work if the Paragraph is > aligned left. > > I have a columnText and a pdftable with one cell. The paragraph is added to > the cell. > If I have 3 chunks and the middle is a DottedLineSeparator then it will only > work if the paragraph is aligned left. > > If I use center or right the bounds are not kept. The text does not stay in > the columnText and the pdftable. I have used fixed width and height for the > table. > > Any clues? Please make a small standalone example reproducing the problem and I'll have a look at it. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ iText-questions mailing list iText-questions@... 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/ |
|
|
Re: DottedLineSeparator and paragraph alignmentHi,
I hope I'm not making a simple mistake here but here is some simple code. package se.edgesoft; import java.io.FileOutputStream; import com.lowagie.text.Chunk; import com.lowagie.text.Document; import com.lowagie.text.Element; import com.lowagie.text.Font; import com.lowagie.text.Paragraph; import com.lowagie.text.pdf.CMYKColor; import com.lowagie.text.pdf.ColumnText; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfSpotColor; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.pdf.SpotColor; import com.lowagie.text.pdf.draw.DottedLineSeparator; public class Test { public static void main(String args[]) { Document doc = new Document(); try { SpotColor pink = new SpotColor(new PdfSpotColor("PANTONE 708 M", 1.0f,new CMYKColor(0.0f, 0.46f, 0.22f, 0.0f))); CMYKColor gray = new CMYKColor(0.0f, 0.0f, 0.0f, 0.2f); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("d:/pdf/test.pdf")); doc.open(); PdfContentByte cb = writer.getDirectContent(); cb.roundRectangle(150, 150, 150, 150, 10f); cb.setColorFill(pink); cb.setLineWidth(1f); cb.setColorStroke(gray); cb.fillStroke(); ColumnText ct = new ColumnText( cb ); ct.setSimpleColumn( 150, 150, 300, 300, 8, Element.ALIGN_LEFT ); /** * Only set the nessesary settings */ PdfPTable table = new PdfPTable(1); table.setTotalWidth( 150 ); table.setWidthPercentage(100); PdfPCell cell = new PdfPCell(); cell.setBorderWidth( 0 ); cell.setVerticalAlignment( Element.ALIGN_MIDDLE ); // Top, Middle, bottom cell.setFixedHeight( 150 ); Paragraph pr = new Paragraph(); pr.setLeading( 12f ); pr.setExtraParagraphSpace(0); /** * If we align left it will work but not right, center */ pr.setAlignment( Element.ALIGN_RIGHT); Font font = new Font(Font.COURIER, 8, Font.BOLD); font.setColor( gray ); pr.add( new Chunk( "This is a test", font ) ); pr.add( new Chunk( new DottedLineSeparator() )); pr.add( new Chunk( "continue", font )); cell.addElement( pr ); table.addCell(cell); ct.addElement( table ); ct.go(); } catch (Exception ex) { ex.printStackTrace(); }finally{ doc.close(); } } } |
|
|
Re: DottedLineSeparator and paragraph alignmentMathias Nilsson wrote:
> Hi, > > I hope I'm not making a simple mistake here but here is some simple code. Either your example doesn't really make sense, or I don't understand what you're trying to achieve. People use the DottedLineSeparator in left aligned paragraphs because they want part of the paragraph to be right aligned. The result is a paragraph that is "justified" on both sides. Now you say: I want to use the DottedLineSeparator, but I want the text to be right aligned. But if you set the alignment to left aligned, using the DottedLineSeparator will also achieve right alignment. Why the need to set the alignment to RIGHT_ALIGNED? I honestly don't understand what you are trying to achieve. I also don't understand why you draw a round rectangle and then wrap a table inside a columntext. Wouldn't it be easier to just draw a table at an absolute position and use a cell event to draw the rounded borders and background? Also what is the point of combining setTotalWidth and setWidthPercentage? Those are contradictory methods. Strange constructs like that confuse me big time, and I find it hard to understand what kind of answer you expect. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ iText-questions mailing list iText-questions@... 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/ |
|
|
Re: DottedLineSeparator and paragraph alignmentMathias Nilsson wrote:
> Hi, > > I hope I'm not making a simple mistake here but here is some simple code. I've added a fix to iText in the SVN repository to avoid that ALIGN_RIGHT or ALIGN_CENTER has any effect if you use horizontal separators. As you can see in the code below, right aligned will be ignored because it doesn't make sense to right or center align a line with a separator count > 0. Modified Paths: -------------- trunk/src/core/com/lowagie/text/pdf/PdfLine.java Modified: trunk/src/core/com/lowagie/text/pdf/PdfLine.java =================================================================== --- trunk/src/core/com/lowagie/text/pdf/PdfLine.java 2009-05-30 10:03:36 UTC (rev 3944) +++ trunk/src/core/com/lowagie/text/pdf/PdfLine.java 2009-05-30 19:11:09 UTC (rev 3945) @@ -254,16 +254,15 @@ return left; } } - else { + else if (this.getSeparatorCount() == 0) { switch (alignment) { case Element.ALIGN_RIGHT: return left + width; case Element.ALIGN_CENTER: return left + (width / 2f); - default: - return left; } } + return left; } -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ iText-questions mailing list iText-questions@... 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/ |
|
|
Re: DottedLineSeparator and paragraph alignmentOk
|
|
|
Re: DottedLineSeparator and paragraph alignmentPardon me for asking but you say that I shouldn't wrap my table in a columntext.
How can I absolute position the table? |
|
|
Re: DottedLineSeparator and paragraph alignmentMathias Nilsson wrote:
> Pardon me for asking but you say that I shouldn't wrap my table in a > columntext. > How can I absolute position the table? With writeSelectedRows (see chapter 6 of "iText in Action"). -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ iText-questions mailing list iText-questions@... 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/ |
| Free embeddable forum powered by Nabble | Forum Help |