0

In our application we are using Itext Pdf 5.5.3 library. We have checked with some of the pdfs in which Checkboxes displayed correctly(check/uncheck) .

However there are some pdf with RadioBoxes and do not display radiobutton(on/off) correctly.

I also use this link to validate pdfs and java code
String[] values = form.getAppearanceStates("Checkbox");
return null values.

Also tried Itext RUPS and found that pdf which are working shows Form Field Names in RUPS Form Tab. And PDfs which are not working do not display form fields.

I tried generating pdf from word document and it doesn't display form fields in RUP , neither I can check/uncheck checkbox in Adobe Acrobat Reader.

What could be the solution to display radiobutton with check on / off ?

Edit - I had created sample web application to reproduce the issue. Please setup attached web application and let me know the fix for the issue.

Please download from this link

csarathe
  • 420
  • 1
  • 5
  • 12
  • Please share a sample PDF. Most likely Bruno's answer (your "form" is not a PDF AcroForm form but merely something with the appearance of a form but not its dynamics) is correct but this way we may make sure. – mkl Sep 12 '16 at 20:36
  • sample1 - http://www.filedropper.com/pdftest2 – csarathe Sep 27 '16 at 11:21
  • sample2 - http://www.filedropper.com/pdfexample_1 – csarathe Sep 27 '16 at 11:24
  • observations - http://www.filedropper.com/observations – csarathe Sep 27 '16 at 11:29
  • Concerning your observations: "PDF How its looking in our UI" - what kind of UI is that? It looks as though it only partially supports PDFs. – mkl Sep 27 '16 at 12:48
  • 2
    Semantically neither of your sample files has check boxes, both have radio buttons (the PDF producer merely chose a check box like appearance for them). Neither has a form element "Checkbox", the radio buttons belong to the "claimsType" form field. In both cases `String[] values = form.getAppearanceStates("claimsType");` returns `[1, Off, 2, 3, 4, 5, 6, 7, 8, 9]`, not `null` (using the current iText version). Thus, how exactly do your sample files relate to your question? – mkl Sep 27 '16 at 13:13
  • What Kind of UI ? Its Ext JS based document panel which uses iframe and shows merged pdf (Itext used) . Java code is shown in this link http://stackoverflow.com/questions/39373744/itext-pdf-merging-checkbox-issue – csarathe Sep 28 '16 at 06:52
  • I have updated question to be specific to radiobutton. Even though its radiobutton it should still show the fields as selected which is not happening correctly , any pointer ? – csarathe Sep 28 '16 at 07:06
  • *"shows merged pdf (Itext used)"* - iText has no component which renders a PDF for a PDF viewer. Thus, you either have programmed your own rendering component (probably based on iText as a PDF parser) or use some third-party component. Does Ext JS provide the PDF viewer component? Whichever it is, that rendering component seems to be buggy in respect to radio boxes. – mkl Sep 28 '16 at 08:34
  • Many JS PDF viewer components are built upon the Mozilla PDF.js project. I just displayed your sample PDFs using the current PDF.js [online demo](http://mozilla.github.io/pdf.js/web/viewer.html) and the radio buttons are properly displayed. Thus, you might want to switch or update your JS PDF viewer. – mkl Sep 28 '16 at 08:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124438/discussion-between-csarathe-and-mkl). – csarathe Sep 28 '16 at 15:02
  • Thanks. Appreciate your quick response. Ext JS component(Window) uses iframe internally and iframe is given a url(server call) to load this PDF. Since its working fine in IE 11 , there is a question if it really a problem with UI component ? You may also want to look at our server side code snippet at this link http://stackoverflow.com/questions/39373744/itext-pdf-merging-checkbox-issue . So ExtJS is playing a role of calling a server code via iframe , its not playing any role to render or parse pdf. – csarathe Sep 29 '16 at 06:25
  • If ExtJS is *not playing any role to render or parse pdf*, which component is? The iframe you mention is not the software component displaying the pdf, it is merely a HTML element. *Since its working fine in IE 11 , there is a question if it really a problem with UI component* - ie11 itself cannot display pdfs. It requires an external program, usually adobe reader, which plugs into it for pdf display. Other browsers use different renderers, and some of those other renderers do not support the full pdf standard. – mkl Sep 29 '16 at 07:31
  • We are facing this issue in Chrome(52.0.2743.82 m) . Is that a known issue with chrome ? , The server side code(of Itext) I mentioned , does it look good ? Appreciate if you can provide some pointer to fix the issue. Can we work on any other mode to quickly reach out to solution ? – csarathe Sep 29 '16 at 10:13
  • The iText code looks ok; especially after taking Chris' remarks into account. Considering the response you got on bugs.chromium.org, you fix the issue by updating Chrome. – mkl Sep 29 '16 at 10:58
  • I have created sample web app for your team to reproduce the issue. Please download from this link - http://www.filedropper.com/web-app – csarathe Oct 25 '16 at 13:56
  • Itext team , As I shared web app to reproduce the issue could you please share your findings ? – csarathe Nov 01 '16 at 06:53

1 Answers1

1

You have successfully discovered the difference between interactive PDF forms and "flat" PDF documents that look like a form to the human eye, but that aren't interactive forms.

To make the "flat" forms interactive, you need to open those flat documents in PDF editing software (e.g. Adobe Acrobat) and you need to add a form field manually.

You can ask Acrobat to guess where it should add fields, but Acrobat will be wrong in many cases for obvious reasons. You always need a human if you want it to be done correctly.

As for creating an interactive PDF from Word... Forget about it. Use OpenOffice or LibreOffice.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165
  • Thanks Bruno for your answer. Quick question - are you saying that checked fields (of flat pdf) can not be displayed correctly by Itext ? – csarathe Sep 12 '16 at 15:14
  • I am saying that the check boxes in a flat PDF are not fields. Your question is wrong for 2 reasons: there are no *checked fields* in a flat PDF and iText does not display PDF. Please do not ask questions that do not make any sense. iText treats PDFs in a correct way, but your question is confusing. – Bruno Lowagie Sep 12 '16 at 15:40
  • Bruno..Thanks for quick reply and sorry if there is any confusion . problem i am facing is for flat pdfs chekbox is showing but checked mark is not showing. Code block that I am using is mentioned in this link http://stackoverflow.com/questions/39373744/itext-pdf-merging-checkbox-issue – csarathe Sep 12 '16 at 15:59
  • The check box is not a check field. How many times do I have to repeat that you have to make it a field??? – Bruno Lowagie Sep 12 '16 at 16:40
  • I have added sample pdf and observations , please can you have a look and suggest. – csarathe Sep 27 '16 at 11:26