TextField value that contains apostrophe converts to copyright sign

Hi,

I am having issue of encoding I believe when my data already have apostrophe(’) in value of TextField, this exactly happens when I do have value for TextField when I do generate pdf. Issue is apostrophe converts into CopyRight Symbol (©) and when I click on TextField, it convert back to apostrophe.

I am looking for consistent result of showing apostrophe inside TextField.

I have attached pdf with similar issue. Can you please review and provide some insight what can be done.

Thanks,
Darshit Patel

Report.pdf (76.4 KB)

@darshpatel

Could you please also share the sample code snippet that you are using to fill the form field? We will test the scenario in our environment and address it accordingly.

Hi Asad,

Please find snippet as below, fyi that does not produce the same error when I generate with my data. Below one works fine when I hard code string as value for field. I also tried RichTextBoxField but still end up with same results.

                    txtField = new TextBoxField(document.getPages().get_Item(pageNumber), new Rectangle(35, 50, 150, 100));
                    txtField.getDefaultAppearance().setFontSize(fontSize);
                    txtField.setPartialName("Test");
                    txtField.setMaxLen(20);
                    
                    txtField.setReadOnly(true);
                    txtField.getCharacteristics().setBackground(Color.getLightGray());
                                            
                    txtField.setValue("Fillable Pdf\'s Test's Pdf");
                                            
                    Border border = new Border(txtField);
                    border.setWidth(1);
                    border.setDash(new Dash((int) 0.1, (int) 0.1));
                    border.setHCornerRadius(4);
                    txtField.getCharacteristics().setBorder(fontAndBorderColor);
                    txtField.setBorder(border);
                        
                    document.getForm().add(txtField, pageNumber);

Please let me know if you come around with any solution.

Thanks,
Darshit Patel

@darshpatel

We tested the code in our environment and as you said, it did not reproduce the error. Could you please share the code snippet which you used to generated the PDF file that was shared in your first post? Also, please try to use Aspose.PDF for Java 21.12 before sharing the code snippet. We will further perform test accordingly and share our feedback with you accordingly.

@asad.ali

I can’t provide snippet that I am using in my code as all values that is entered in TextBoxField coming from database and given example resembles the most.

The only scenario that you can do from your end now is you create a table with some columns and enter values that I have provided in pdf and generate pdf from database values.

That is possible to try on your end and that is only feasible as I can not share complete database with you.

Regards,
Darshit Patel

@darshpatel

We are checking it and will get back to you soon.

@darshpatel

We have logged an investigation ticket as PDFJAVA-41187 in our issue tracking system to further look into the details of this case. We will further check it and let you know as soon as the ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

Were you able to reproduce the issue?

Thanks,
Darshit Patel

@darshpatel

No, we were not able to reproduce the issue at our end. We will be checking the case from other perspectives as well. Which is why we have logged an investigation ticket. Furthermore, please note that we tested the case using 21.12 version of the API and could not replicate the scenario. Can you please confirm if same API version is too creating an issue at your end?

Also, can you please share how you are creating the fillable PDF? Are you receiving it from different source OR creating it on your own using Aspose.PDF? Please share the PDF document without filling it so that we can include it in our investigation and further proceed to assist you accordingly.

PS: A similar case has already been discussed on Adobe Forums. You can also go through it and compare your scenario in case it helps. We also viewed the PDF document in Chrome Browser and noticed that the Copyright symbol did not show up there.

@darshpatel

We were able to reproduce the issue using below code snippet:

        Document document = new Document();
        Page page = document.getPages().add();
        TextBoxField txtField = new TextBoxField(page, new Rectangle(35, 50, 150, 100));
        txtField.getDefaultAppearance().setFontSize(10);
        txtField.setPartialName("Test");
        txtField.setMaxLen(20);
        txtField.setReadOnly(false);
        txtField.getCharacteristics().setBackground(Color.getLightGray());

        txtField.setValue("Fillable Pdf\'s Test's Pdf");

        Border border = new Border(txtField);
        border.setWidth(1);
        border.setDash(new Dash((int) 0.1, (int) 0.1));
        border.setHCornerRadius(4);
        txtField.setBorder(border);
        document.getForm().add(txtField, 1);
        document.save(dir+"output_ReadOnly_false.pdf"); 

As a workaround, you can explicitly set the font for the TextBoxField.

The next code snippet creating correct pdf file:

        Document document = new Document();
        Page page = document.getPages().add();
        TextBoxField txtField = new TextBoxField(page, new Rectangle(35, 50, 150, 100));
        txtField.getDefaultAppearance().setFontSize(10);
        txtField.setPartialName("Test");
        txtField.setMaxLen(20);

        txtField.setReadOnly(false);
        txtField.getCharacteristics().setBackground(Color.getLightGray());

        txtField.setValue("Fillable Pdf\'s Test's Pdf");
        txtField.getDefaultAppearance().setFontName("Arial");

        Border border = new Border(txtField);
        border.setWidth(1);
        border.setDash(new Dash((int) 0.1, (int) 0.1));
        border.setHCornerRadius(4);
        txtField.setBorder(border);
        document.getForm().add(txtField, 1);
        document.save(dir+"output_ReadOnly_false_arial.pdf");

The result pdf file and screenshot are attached too.
out_screenshot_2.png (14.3 KB)
output_ReadOnly_false_arial.pdf (77.0 KB)