Skip to main content
Inspiring
July 20, 2007
Answered

iText and setExtraMargin

  • July 20, 2007
  • 1 reply
  • 1697 views
I've been going around and around on trying to get a properly formatted flat pdf created with my data. I have to say that Adobe's ability to actually format a multi-line field as it was presented when it was editable is frustrating. CFMX8, pdfTK and iText all have the same problem of aligning the data in a multi-line field to the top when the pdf is flattened. activePDF is the only app i've found that does the formatting correctly, but they have SO many other issues with correctly populating a complex form that I'm back to trying to make something like iText work correct.
I found this function for iText called setExtraMargin(); and it works perfect with the values 0, 6 to jog the text down. Now my problem is how to set this dynamicly based on if the the field is multi-line or not.

I found this bit of code, but I'm not able to figure out how to convert this to <cfscript>. I need to be able to loop over something like this for each form key/value pair I'm inserting back into the pdf template.

Any help would be great.

I'm currently testing on MX8 if it makes a difference. Altho i will eventually trying to make this work on a cf4.5.1 server.

--Dennis--

This topic has been closed for replies.
Correct answer Racine
Try this code, maybe it will clarify things. I'm assuming you're using a version of iText that supports setExtraMargin(). MX7 does not.

Create a PDFName object before the loop:
PdfName = createObject("java","com.lowagie.text.pdf.PdfName");

Change the FOR loop to



Perfect!

For the record, I did have to the alter the code slightly but it works. Too bad this isn't the default. Altho I guess from what i heard this is a acrobat issue of some sort.

Thanks again for all the help!

1 reply

Inspiring
July 20, 2007
Racine wrote:
> I'm currently testing on MX8 if it makes a difference. Altho i will eventually
> trying to make this work on a cf4.5.1 server.

cf4.5? can't recall, does it do java cfx tags? if not, forget it.

in any case, first thing is to make sure that code works w/the iText version
that comes w/cf. what version is that snippet from? if it's very modern then
you'll probably need to use mark mandel's javaLoader to load the newer jar.

RacineAuthor
Inspiring
July 21, 2007
My main issue is how to get the multiline attribute out of the field name (PdfFormField.FF_MULTILINE doesn't work in cfscript)
If I can find out how to get that value the rest of the logic is easy.
Inspiring
July 22, 2007
I guess I'm still missing something. Shouldn't I be able to get a value that tells me that a specific field is multiline? I thought the FF_Multiline was specific to a given field?
Try this code, maybe it will clarify things. I'm assuming you're using a version of iText that supports setExtraMargin(). MX7 does not.

Create a PDFName object before the loop:
PdfName = createObject("java","com.lowagie.text.pdf.PdfName");

Change the FOR loop to