How to remove border from text-boxes during html to pdf conversion (CTS-5398)

Hi,

While converting attached html file to pdf using latest Aspose.Pdf (java), I can see that the fixed border gets added in the output, we don’t see any such borders when we open html file in any browser. Is there any way to get rid of such borders from all text boxes ? This looks like a bug to me.

Border_field_issue.zip (261.8 KB)

Thanks,
Rajiv

@rajivrp,

We managed to replicate the problem of text box borders in our environment. It has been logged under the ticket ID PDFJAVA-37516 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

Thanks Imran … can you confirm whether this behavior is specific only to this file OR this will happen for all html files wherever text-boxes are used.

Regards,
Rajiv

@rajivrp,

By default all HTML forms are converted to a fill able PDF forms with default PDF form styles. If there is no need for it, then the following code could be used:
Java

String basePath = "C:\\Pdf\\test709\\";
HtmlLoadOptions htmloptions = new HtmlLoadOptions();
Document doc = new Document(basePath + "Border_field_issue.htm", htmloptions);        

// delete borders
for (Field field : doc.getForm().getFields()) {
  field.getBorder().setWidth(0);
}        
                
doc.flatten(); // Removes all fields and place their values instead.         
doc.save(basePath + "Output.pdf");

The linked ticket ID PDFJAVA-37516 has been closed.

Hi Imran,

Well, with this workaround it’s not producing good output, it actually gets worst, layout of the file gets distorted completely. Pls check the attachment. You need to reopen the bug.

outputfile1065173445.pdf (54.5 KB)

Thanks,
Rajiv

@rajivrp,

You are using an old version 17.10 of Aspose.PDF for Java API. Please download and try the latest version 18.2 of Aspose.PDF for Java API. This is the output PDF: Output18.2.pdf (271.9 KB)

Thanks @imran.rafique … I am able to produce the desired output now.

I am just wondering … would such logic (literally traversing through every field of every form in the file via for-loop) not have a significant performance impact especially while dealing with large pages with many forms / fields ? Can you pls confirm that there is no other better way to achieve the same behavior ??

Rajiv

@rajivrp,

In order to improve the performance, you can optimize the source PDF document, and then process form fields. However, we recommend you to please share each problematic PDF document and code. We will investigate and share our findings with you.