Quantcast

ColumnText setSimpleColumn with getFieldPositions()

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

ColumnText setSimpleColumn with getFieldPositions()

mpickell

I am having an issue where I am stamping a PDF template.

Here is my setup:

I have a PdfStamper and a template with a bunch of form fields on it. I am using some of the form fields as placeholders for PdfPTables that I create in java. So I get my place holder dimensions like this:

float [] fieldPositionsStatement = form.getFieldPositions("statement");

then i pass fieldPositionsStatement to a class that will set up my columnText like this:

(new PdfStatementTable()).addStatementTable(bill, stamper.getOverContent((int)fieldPositionsStatement[0]), fieldPositionsStatement)

which calls this method


	public void addStatementTable(SewageBill bill, PdfContentByte cb, float[] pos) {
		
		ColumnText c1 = new ColumnText( cb );
		
		// Why do i need to add 50 to the X factors??? 
		c1.setSimpleColumn( pos[1] - 50f, pos[2] - 50f, pos[3] + 50f, pos[4] );
		
		c1.addElement(createTable(bill));
		try {
			c1.go();
		} catch (DocumentException e) {
			throw new RuntimeException(e);
		} 
       }

So my problem is that when i call setSimpleColumn, I need to expand the column text with arbitrary values for some reason. The place holder coordinates that i am using are resulting in a columnText that is smaller than the place holder -- by a percentage it seems.

I use this basic method to fill in two separate sections which are different sizes. In one i need to add 50f, the other i need to add 20f.

is there padding or something that I am missing that i need to remove from the columnText? I can't find any in debug mode when i interrogate the fields.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ColumnText setSimpleColumn with getFieldPositions()

iText mailing list
pickm wrote:
> So my problem is that when i call |setSimpleColumn|, I need to expand
> the column text with arbitrary values for some reason.

How do you know this?
Did you draw a rectangle using the coordinates returned by
getFieldPositions? Does it appear at the correct place?
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
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.itextpdf.com/book/
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: ColumnText setSimpleColumn with getFieldPositions()

mpickell

No, I did not write a rectangle to test my original assertion. I have now gone back and I drew a rectangle. It appears to be correct. Here is the test code i used:

		PdfContentByte c = stamper.getOverContent(1);
		Rectangle r = new Rectangle(fieldPositionsStatement[1] , fieldPositionsStatement[2] , fieldPositionsStatement[3] , fieldPositionsStatement[4]);
		r.setBackgroundColor(BaseColor.RED);
		c.rectangle(r);
		c.stroke();

What I did that caused my original question was to add a PdfPTable to the columnText. The PdfPTable had margins on both sides.

So... we have eliminated my suggestion that the coordinate positions are the problem. Any idea why i put a PdfPTable into the ColumnText and have wide margins so that i am required to stretch the table?

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ColumnText setSimpleColumn with getFieldPositions()

iText mailing list
pickm wrote:
> What I did that caused my original question was to add a PdfPTable to
> the columnText. The PdfPTable had margins on both sides.

The width percentage is 80% by default.
You need to change it to 100%.

> So... we have eliminated my suggestion that the coordinate positions are
> the problem.

Yes, great!
The original problem worried me.
I'm happy that we've ruled that out.

> Any idea why i put a PdfPTable into the ColumnText and have
> wide margins so that i am required to stretch the table?

I'd try changing the width percentage.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
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.itextpdf.com/book/
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: ColumnText setSimpleColumn with getFieldPositions()

mpickell
That fixes it.  Thanks!  

I got widthPercentage (the table) confused with widthPercentages (the columns)... I assumed they were the same thing.
Loading...