pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Mulder <ammul...@gmail.com>
Subject Re: Pdfbox 2.0 Forms
Date Wed, 22 Jun 2016 11:21:54 GMT
So I've had an issue with a third-party PDF with forms where once I
complete the form the layout of the completed form field text is
slightly different in Preview on the Mac compared to Acrobat Reader on
Windows, and also across browsers with built-in pdf rendering.  For
instance, the text might be offset down and to the left a few pixels
on one platform, or a font size that fits fine on one platform gets
cut off on another.

I notice that the NeedAppearances flag is set to true.  I'm not really
familiar with this flag, but it sounds like you're saying it means the
renderer should make up an appearance to use.

Could that be the problem?  Do I need to just manually specify an
appearance for each field to make it show exactly the same on each
platform?

I guess the other question is, some of the fields (both "text boxes"
and "text areas") can take a somewhat arbitrary amount of text -- is
part of the purpose of NeedAppearances to allow the renderer to select
a font or scaling that fits all the text in the available space of the
field?  Though the form field itself has a font defined (in /DA).  I
guess I'm a little confused as to what the appearance stream is
supposed to do for a form field.

Here's the example (layout good on Mac/Preview, bad on Windows/Reader,
in between on Mac/Chrome): http://princecon.org/gnome.pdf  In this
case the main content is the original empty PDF, and all the field
values are specified in the revision(s) at the end of the document.

Thanks,
       Aaron


On Wed, Jun 22, 2016 at 5:07 AM, Maruan Sahyoun <sahyoun@fileaffairs.de> wrote:
> Hi,
>
>> Am 22.06.2016 um 10:55 schrieb DJ.Larry@gmx.de:
>>
>>
>>
>> Hello,
>>
>> i have a little problem after update from 1.8 to 2.0.
>>
>> I open a pdf form, witch was created from libreoffice, fillout the form, and show
it with pdfrenderer.
>> After update to 2.0 the fill out form fields was not shown at image.
>> When i save the document to file, the fill out data are included.
>>
>> Code:
>> ---------------------------
>> PDDocument doc = PDDocument.load(new File(Client.class.getResource("/resources/pdf/template.pdf").getFile()));
>> PDAcroForm form = doc.getDocumentCatalog().getAcroForm();
>> for(int i = 0; i<list.size(); i++) {
>> String fieldname = "field"+(i+1);
>> form.getField(fieldname).setValue(((ListObject)list.get(i)).getText());
>> }
>>
>> PDFRenderer pdfRenderer = new PDFRenderer(doc);
>>         try {
>>             ImagePanel panel = new ImagePanel(pdfRenderer.renderImageWithDPI(viewPage,
300, ImageType.RGB),zoom);
>>             scpanel.setViewportView(panel);
>>             panel.repaint();
>>
>>         } catch (IOException e) {
>>             // TODO Auto-generated catch block
>>             e.printStackTrace();
>>         }
>> ---------------------------
>> Anyone has an idea, why the form data not shown but save?
>
>
> without looking at the PDF it's difficult to tell but it might be realted to https://issues.apache.org/jira/browse/PDFBOX-3356
>
> BR
> Maruan
>
>
>>
>> Greets
>> Lars
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>

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


Mime
View raw message