Hi

Files can be found here  https://ufile.io/f/svrzb

what happens when you remove the line pdForm.setNeedAppearances( true ); or set to false?

This doesn't change the PDFBox rendering, but does change Acrobat and Edge where the third field value isn't displayed until clicked.

Thanks


On Thu, 02 Feb 2023 20:19:38 +0200, sahy...@fileaffairs.de <sahy...@fileaffairs.de> wrote:

Hi,

what happens when you remove the line pdForm.setNeedAppearances( true
); or set to false?

The attachments didn't make it to the mailing list - can you upload
these to a shared location?

BR
Maruan

Am Donnerstag, dem 02.02.2023 um 19:30 +0200 schrieb Jurgen Doll:
Hi

I have PDF forms which when opened and rendered as an image with
PDFBox don't display the contents/values of all the populated
fields.  However the same PDF files render all fields correctly in
Acrobat and Edge. Specifically it seem that text fields that appear
to render each letter in a box (combing?) are displayed with PDFBox,
but 'unspaced' textfield values are not rendered.

I would like to know if there is some way that I can detect that a
field won't be rendered and to correct it via PDFBox code before
rendering.

Additional information:

The PDF forms originate from other independent organizations, which
are consumed and populated by my application.

I've attached stripped down versions (just three fields) of one of
these forms, namely EmptyForm.pdf (unpopulated) as consumed by my
application and then PopulatedForm.pdf after field processing and
then saved (all via PDFBox API).

Below basic PDFBox code that I use to achieve this:

try ( var pdfDoc = PDDocument.load( new File("EmptyForm.pdf") ) )
{
    var pdForm = pdfDoc.getDocumentCatalog().getAcroForm();
    pdForm.setNeedAppearances( true );  //*1

    for ( var field : pdForm.getFields() )
    {
        var fldValue = getValueFor( field.getPartialName() );
        field.setValue( fldValue );
    }

    pdForm.refreshAppearances();  //*1
    var pages = new PDFRenderer( pdfDoc );
    var pgImage = pages.renderImage(0);

    // display pgImage: only two fields have been rendered NOT three
?

    pdfDoc.save( "PopulatedForm.pdf" );
}
catch ( IOException IO )
{
    IO.printStackTrace();
}

//*1 Without these two lines Acrobat and Edge also exhibit the same
behavior as PDFBox


This happens using JRE 11 and PDFBox  2.0.24,  2.0.27, as well as
3.0.0 alpha3

Thanks in advance
Jurgen


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