We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

UTF-8 Char - Server hangs - How to handle in Aspose.pdf for Java

Hi,Test_PDF_UTF8_FullUTF8String.zip (1.6 KB)

We are using Aspose to generate the PDF by fetching the user entered data from database. So, users are free to enter the data in any language. Because of this, the data contains various UTF-8 characters. Could you please help me how to handle any kind of UTF-8 Char in Aspose.pdf for java.

I am attaching a simple program to simulate the issue, which would have all the UTF-8 characters to add to PDF.
It increases the CPU utilization and also the PDF generated finally does’t get open.

Basically need to know that once all the data is added in the PDF (i.e. com.aspose.pdf.Document), can we do any changes to it for making it suitable for UTF-8 or any other solution?

NOTE :: We are using AsposePdf for Java version 10.3
Appreciate your help.


Thanks for contacting support.

We have tested the scenario with Aspose.Pdf for Java 17.8 while modifying your code accordingly as follows and observed that CPU utilization was up-to 60% and generated document was also opened successfully in Adobe Reader.

For your reference, I have attached generated output as well (TestPDFFile.pdf). However in the attached file, there are some characters which are missing, but this issue is related to missing fonts in the system.

Please note the UTF-8 Characters Encoding contains more than 100k entries and it is quite difficult for any font to support all those characters. Though Arial Unicode MS Font supports maximum language characters in UTF-8 standard but does not cover all.

I am afraid that there is no such method or property supported in the API which helps to determine unsupported UTF-8 characters in the PDF document, which is being generated. As shared above, you need to install all those fonts in your environment which are essential to support all language characters, with which you are dealing.

Furthermore, please try using latest version, as it is always recommended to use it, because it contains more fixes and performance improvements. In case if you have any supported font installed in your system and still facing missing characters or performance issue, please let us know. We will test the scenario in our environment and address it accordingly.

Hi Asad,

Thanks for a quick reply.
As you mentioned that the CPU Utilization was up-to 60%, if you run the program multiple times simultaneously, you would be able to see that it will reach 100% also. and as soon as that happens, our application stops responding to other users who are logged into system.

Because that CPU Utilization remain high for a long time … it doesn’t come down quickly.

How we can handle such scenario?



Thanks for writing back.

We have tested the scenario by executing the code multiple time simultaneously, like following and observed that the CPU usage went up-to 100%. So we have logged a performance issue as PDFJAVA-37045 in our issue tracking system. We will further investigate the issue in details and keep you updated with the status of its correction. Please be patient and spare us little time.

List<Callable<Void>> taskList = new ArrayList<Callable<Void>>();
Callable<Void> callable = new Callable<Void>()
 public Void call() throws Exception
  return null;
ExecutorService executor = Executors.newFixedThreadPool(3);
try {
 List<Future<Void>> futureList = executor.invokeAll(taskList);
} catch (InterruptedException e) {
 // TODO Auto-generated catch block

We are sorry for the inconvenience.


Thanks for your patience.

We have further investigated the earlier logged issue and our investigation has shown following results:

1 task (1 pool) - 24-30% CPU usage
2 tasks (2 pools) - 50% CPU usage
3 tasks (3 pools) - 75-80% CPU usage
4 tasks (4 pools) - 75-95% CPU usage (depends on how many other programs use CPU)
5 tasks (4 pools) - similarly for 4 tasks (4 pools)

The sample code, shared earlier, was run on Windows 10, Java 1.8.0_45, Aspose.Pdf for Java 17.9 with 3,5GB heap space and processor Intel Core i3-6100 3.70Ghz.

This processor has 4 cores and if runs 4 pools with 4 or more tasks CPU usage about 100%, which is normal about 20-30% of CPU for every pool. In case you want to work without hung, you should use the Aspose.Pdf library code in a limited number of threads (tasks) according to your processor.

Please also note that, in version 17.10 of the Aspose.Pdf for Java has some more improvements for multi-threading environment. Please try using the latest release version Aspose.Pdf for Java 17.10 and in case you face any issue, please feel free to contact.