Convert txt to pdf using Aspose.Word stuck

Hello,

I am using Aspose.Word java latest version (21.9) to convert txt to pdf.
When I run conversion in docker desktop on Windows, conversion completes without error.
When I run conversion in cloud (k8s) from the same docker file, conversion process stuck forever.

Can you please advice what can I do to get similar behavior in both docker environments?

Code used:

LoadOptions loadOptions = new LoadOptions();
loadOptions.setLoadFormat(LoadFormat.TEXT);
Document doc = new Document(source, loadOptions);

ByteArrayOutputStream target = new ByteArrayOutputStream();
doc.save(target, SaveFormat.PDF);

Thanks.

@ainvig,

Please ZIP and upload your source TXT file (that you are getting this problem with) here for testing. Do you only see this problem when converting TXT to PDF format or TXT to DOCX also causes the same problem on your end? Also, do you see this problem with one particular TXT file or all text files you try to convert to PDF cause the same issue?

Thanks for you reply.
Unfortunately I can not upload source TXT file, getting error, it is possible that file is too big (89MB)

Do you only see this problem when converting TXT to PDF format or TXT to DOCX also causes the same problem on your end?

Yes, problem exist only when converting TXT to PDF. I have tried to convert TXT to DOCX, it is working fine.

Also, do you see this problem with one particular TXT file or all text files you try to convert to PDF cause the same issue?

I have generated random txt file with similar size ~89MB. It won’t convert to PDF too.

@ainvig,

There is no limit on maximum size of TXT file that Aspose.Words can process or convert to PDF. The only limit is the amount of RAM (memory) available on your side.

Please note that usually Aspose.Words needs few times more memory than document size to build model of the document in memory. For example, if your document’s size is 1 MB, Aspose.Words needs 10-20 MB of RAM to build its DOM in memory. Multiplier depends on format because some formats are more compact than others. For example DOCX format is more compact than DOC and RTF, and DOC is more compact than RTF.

In your case, you can try to estimate how much memory Aspose.Words actually consumes during converting your particular TXT file to PDF on docker desktop on Windows and then allocate similar amount of memory on cloud (k8s).

I got your point, thank you.
There is my observations about memory consumption.

Docker desktop on Windows:
1GB of heap is enough to complete conversion of 89MB TXT file.

cloud k8s:
Pod resources (requests, limits) memory was set to 16GB. JAVA_OPTS=-XX:MinRAMPercentage=25.0 -XX:MaxRAMPercentage=75.0
I see that application consume from 2GB to 4GB of memory, while converting TXT to PDF.
I have checked max heap size available for jvm process it is ~13GB.

Please advise, what can be a cause of this inconsistent behavior?

@ainvig,

Please tell, how much time it takes to successfully perform TXT to PDF conversion on this environment?

Please also compress your sample TXT file(s) (that you are getting this problem with) into ZIP format and attach the .zip file here for testing. We will then investigate the issue further on our end and provide you more information.

It takes 23 seconds.

Please also compress your sample TXT file(s) (that you are getting this problem with ) into ZIP format and attach the .zip file here for testing. We will then investigate the issue further on our end and provide you more information.

link to zip file: UPLOAD.EE - File does not exist

@ainvig,

We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-22869. We will further look into the details of this problem and will keep you updated here on the status of the linked ticket. We apologize for your inconvenience.

I think that I found the reason of inconsistent behavior between docker desktop on Windows and k8s.
Docker desktop on Windows it is my local development environment and I do not activate license there.
Without license aspose.word do not convert whole file (89MB), only small part, that’s why conversion of 89MB file takes only 23 second.
After applying license I get converted pdf file.
It takes ~8 minutes to convert 89MB CSV file to PDF.
Will it help to increase conversion speed if I will use another aspose product e.g. aspose.pdf?

@ainvig,

Yes, Aspose.Words, when used in evaluation mode (without applying license), will process a few Paragraphs during conversions.

Aspose.PDF’s program kept running for more than 30 minutes on our end and we had to terminate it as it was taking unexpectedly extra amount of time during converting the TXT file you supplied earlier to PDF. We are checking this scenario further and will get back to you with more information soon.

@ainvig

Another ticket as PDFJAVA-40976 has been logged in our issue management system to investigate the behavior of Aspose.PDF for Java API while converting your .txt file into PDF. We will further let you know as soon as the ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

@ainvig We have implemented performance improvement in Aspose.Words. However, your issue has been closed as ‘Won’t Fix’ because your document is simply too large. Currently it takes about 8minutes to process 89MB text file. But it is strongly not recommended to use such large documents. It is recommended to split such document into parts.