pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Timo Rumland" <timo.ruml...@digitalys.de>
Subject RE: PDF form: Strange behavior with filled out textfield (only visible after clicking the field)
Date Mon, 09 May 2016 07:58:34 GMT
Hello,

> I'm trying to fill out a PDF form with PDFBox 2.0.0 (using Java 6).
> [...]
> But opening the saved file with PDF XChange Viewer (2.5), which is 
> what our clients use, I have the following problem:

ok I think the problem really was part of the PDF Xchange Viewer itself. I
updated the viewer to the latest version and the problem disappeared.

I'm happy that my PDFBox code is working and I didn't do anything wrong to
fill out the PDF form fields.



Best regards,
Timo Rumland







-----Urspr√ľngliche Nachricht-----
Von: Timo Rumland [mailto:timo.rumland@digitalys.de] 
Gesendet: Sonntag, 8. Mai 2016 23:25
An: users@pdfbox.apache.org
Betreff: PDF form: Strange behavior with filled out textfield (only visible
after clicking the field)

Hello,

I'm trying to fill out a PDF form with PDFBox 2.0.0 (using Java 6). My test
PDF file is a really simple PDF form, containing only one text label and one
text field named "textfield01". When I run my code to fill out that single
form field with the string "test", no error occurs.

Opening the saved file with Acrobat Reader DC, the text field contains the
string "test".

But opening the saved file with PDF XChange Viewer (2.5), which is what our
clients use, I have the following problem:

First, the text field is empty. Strangely, after clicking into that text
field, the string "test" appears. After losing the focus, the text
disappears. When I then edit the contents of the text field and the text
field loses focus, the text remains visible (all with using PDF XChange
Viewer).


If you may, you can download my Test-PDF form file here:
https://goo.gl/y03zht


Please, see this simple example code, which shows how I fill the textfield:

----

PDDocument pdDocument = PDDocument.load( new File(
"g:/2016-05-08_test-form.pdf" ) );

PDDocumentCatalog pdDocumentCatalog = pdDocument.getDocumentCatalog();
PDAcroForm pdAcroForm = pdDocumentCatalog.getAcroForm();

String pdFieldName = "textfield01";

PDField pdField = pdAcroForm.getField( pdFieldName ); if ( pdField == null )
    throw new RuntimeException( "Failed to fill PDF field: Given field '" +
pdFieldName + "' is unknown" );

pdField.setValue( "test" );

File file = new File( "g:/test-form_out.pdf" ); FileOutputStream
fileOutputStream = new FileOutputStream( file );

pdDocument.save( fileOutputStream );
pdDocument.close();

fileOutputStream.close();

----


I don't think this is a bug with PDFBox. Maybe I do something wrong or the
PDF XChange Viewer has some strange behavior. Whatever the cause is, I
really need to be able to safely fill out a PDF form which values then must
be visible within that PDF viewer.


As a side note: I create the PDF form by creating a file with LibreOffice
Writer, insert a text field and export it via PDF. Maybe that PDF file has a
"problem"? Unfortunately I have no knowledge about the PDF specification to
decide if hat may be the case.



I really appreciate any help you can offer


Thanks a lot!


Best regards,
Timo Rumland


---------------------------------------------------------------------
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