The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

saladfingers (1) [Avatar] Offline
we ran into the following problem: We get PDF-templates (built with Lifecycle Designer) and fill them using iText PDFStamper - so far it works great. But now we got new templates and some of them contain multiline TextFields with a particular font and font size, the text is defined as justified and should have a reduced line spacing. There is no problem with the font and font size. But after filling with iText the text is not justified and the line spacing is ignored. The text-alignment works with left and right, but not justified. I read about defining a ColumnText or Paragraph to solve that problem, but that is not really an option because we'd have to make ugly workarounds for these particular textfields. Is there another way to fix this? Why is "justify" and the line spacing ignored?

Thanks in advance...
blowagie (284) [Avatar] Offline
Re: Formatting with PDFStamper
iText can fill out static XFA forms (you call them PDF templates built with Livecycle Designer) because it ignores the XFA and only looks at the corresponding AcroForm fields that are inside the PDF file.
This means that iText can only see the information that is present in those fields.

If you look at the PDF Reference p624, you'll find out that the alignment is called 'quadding'; iText looks for the quadding by retrieving the value of the /Q key in the annotation dictionary that is responsible for visualizing the field. Let me quote the reference manual:

Q integer (Optional; PDF 1.4)
A code specifying the form of quadding (justification) to be used in displaying the annotation’s text:

0 Left-justified
1 Centered
2 Right-justified
Default value: 0 (left-justified).

In other words: when you say "the text is defined as justified," that may be true for the XFA flavor of the form in your PDF template, but that's simply not true for the AcroForm version of that same form, because 'justified alignment' doesn't exist. It's not in the reference manual, so it's not implemented for AcroForms.

Either you buy the Livecycle Suite to fill those forms, or you use the 'ugly' workaround with iText. There are no other options smilie
blowagie (284) [Avatar] Offline
Re: Formatting with PDFStamper
By the way: please don't use this forum for questions, use the mailing list instead!!!