Hi,

> Am 24.07.2016 um 14:35 schrieb Aaron Mulder <ammul...@gmail.com>:
> 
> I am filling out a form on an existing PDF document.  The base
> document has /NeedAppearances true and the result is that the text
> looks different on every viewer.  For instance, on some the text is
> offset vertically or the text is cut off when using a font that works
> fine on a different viewer.
> 
> I gather the solution to this is to set /NeedAppearances to false and
> provide an appearance stream for every field.  I don't know much about
> appearance streams.
> 
> In looking at the output of the PDFBox examples, it seems that the
> appearance stream actually writes the field's value as text, e.g. for
> the form containing the text "Sample field" the appearance stream is:
> 
> /Tx BMC
> q
> 1 1 198 48 re
> W
> n
> BT
> /Helv 12 Tf
> 2 20.692 Td
> (Sample field) Tj
> ET
> Q
> EMC
> 
> Is there a way to not include the specific text in the appearance
> stream such that if the user changes the value in the field then the
> appearance stream will still work?

If the field has a value then this value will be part of the appearance stream. 
But that doesnÄt mean that the value can not change. When the user enters new 
text then the viewer will recalculate the appearance stream and the new text 
will replace the old one.

> 
> Really all I want from the appearance stream is to specify the font
> and bounds and offset such that the text is in exactly the same place
> on every viewer and the same font size fits into the available space
> on every viewer.

The font (/Helv in your example) and font size (12 in your example) are part of 
the fields properties and specified in the default appearance string. This will 
make it into the appearance stream. Unfortunately setting such as bounds and 
offset are not part of the PDF specification but implementation specific. So 
you might get different results with different viewers.

One thing you should also ensure is that the fonts used for forms filling are 
embedded in the PDF so that all viewers can use the same font.


> 
> And one more question -- the document has let's say 200 fields, and I
> only populate maybe 50 of them.  If I specify appearance streams for
> *only* the ones I populate, will that work?  If that's the case,
> should /NeedAppearances be set to true or false?

If the appearance stream for the filled out fields is defined then you should 
set /NeedAppearances to false (or remove the key completely).

BR
Maruan

> 
> Thanks,
>       Aaron
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to