pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steffen R." <raubvoge...@googlemail.com>
Subject Problem with Unicode text in PDF form text field
Date Wed, 12 Jun 2013 08:18:19 GMT
Hello,

I am facing a problem that might be a bug. This is the scenario: Loading a
PDF, filling in some form text fields and saving it back to PDF. When I do
this

PDDocument doc = null;
        try
        {
            doc = PDDocument.load( "Test.pdf" );

            PDAcroForm form = doc.getDocumentCatalog().getAcroForm();
            PDVariableText field = (PDVariableText)
form.getField("testField");
            field.setValue("Test it 123456789012345 äüö?ß! á Ф ф Й й
άγγελος");

            doc.save( "TestFilled.pdf" );
        } catch (COSVisitorException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally
        {
            if( doc != null )
            {
                try {
                    doc.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

with the attached PDF file (created from scratch with Acrobat XI Standard),
the field is filled in the saved PDF file but the characters are not
presented as in code. And now the most curious thing: If you click into the
form field then the correct text will be shown. Very strange.

Is someone facing a similar problem? Is this a known bug? Does a workaround
or patch exist?

I took a look at the source code. It seems that beside the normal field
value an additional "appearence" for showing the field value is added which
maybe doesn't support unicode the way it is implemented atm.

Thanks in advance for any help,
Steffen Harbich

Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message